您的位置:首页 > Web前端 > JavaScript

jsp:include 使用jsp:param乱码解决

2012-07-24 00:24 393 查看
如果jsp:include 中的page页面存在乱码 ,则需要在使用<jsp:include page=""> 的页面中的<body>后加上

<%

request.setCharacterEncoding('UTF-8") ;//或者指定的编码(GBK或其他)

%>

如下面所示:

jsp-include.jsp

<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<html>
<head><title>jsp include测试页</title></head>
<body>
<%
request.setCharacterEncoding("UTF-8") ;
%>
<h3>jsp include 指令测试</h3>

<jsp:include page="forward-result.jsp">
<jsp:param name="age" value="32" />
<jsp:param name="username" value="张三" />
</jsp:include>

</body>
</html>

forward-result.jsp

<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<html>
<head><title>forward的结果页</title></head>
<body>

年龄:<%=request.getParameter("age")%><br />
姓名:<%=request.getParameter("username") +"--11"%>

</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: