弄了两个小时终于解决了!!!
问题:在一页面的url传中文,从一页面跳转到二页面,在二页面中得到url中的中文乱码!
解决办法:在一页面的url用encodeURIComponent转两次码(解决非法字符和中文乱码),
window.location.href="edit.jsp?content="+encodeURIComponent(encodeURIComponent("我是"));
在二页面中
<%
String content=request.getParameter("content");
content=URLDecoder.decode(content,"utf-8");//对中文参数进行解码
%>
<textarea style="width:1050;height:285px;resize:none;"><%=content %></textarea> </td>
textarea中值便为:我是
本文介绍了一种解决网页URL中传递中文字符导致的乱码问题的方法。通过使用encodeURIComponent对中文进行两次编码,并在接收端使用URLDecoder.decode进行解码,确保了中文字符能正确显示。
538

被折叠的 条评论
为什么被折叠?



