java: jsp:param中文亂碼


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>

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM