jsp与jsp页面之间传值中文,页面显示乱码问题

xxx.jsp 页面传值到 confirm.jsp 页面

在拼接url时,对于中文名称字段应该加上 encodeURIComponent 方法,对中文进行十六进制编码

window.location.href = "${ctx}/cms/manage/confirm.jsp?applicantName="+encodeURIComponent(applicantName); 

 

confirm.jsp页面接收

因为这里是ISO-8859-1编码的 所以需要转换 <%=new String(request.getParameter("applicantName").getBytes("ISO-8859-1"),"utf-8") %>

<tr name="postalAddress">
  <td>收件人:</td>
  <td ><input type="text" id="Addresser" name="Addresser" value="<%=new String(request.getParameter("applicantName").getBytes("ISO-8859-1"),"utf-8") %>"/></td>
</tr>

 

posted on 2020-03-04 18:20  多言  阅读(553)  评论(0编辑  收藏  举报

导航