java: jsp:param中文乱码

假如a.jsp/b.jsp文件中

 

a.jsp代码:

需要加入:request.setCharacterEncoding("UTF-8") 

 

<%@ 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>

  

b.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>

  

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-05
  • 2021-12-07
  • 2022-01-09
  • 2021-08-21
猜你喜欢
  • 2021-10-20
  • 2022-02-15
  • 2022-12-23
  • 2021-06-21
  • 2021-11-16
  • 2021-05-19
  • 2021-09-29
相关资源
相似解决方案