比如:
http:localhost:8080/tets/test.action?username=" "
username="中国"
首先应对中文进行url编码: username=URLEncoder.encode("中国","UTF-8");
然后再接受的jsp页面进行转换:
<%
=new string(request.getParameter("username").getBytes("ISO8859-1"),"UTF-8")
%>
最后进行解码:
导入java.net.URLDecoder类
<%
=URLDecoder.decode(new string(request.getParameter("username").getBytes("ISO8859-1"),"UTF-8"),"UTF-8")
%>
本文介绍了如何对中文参数进行URL编码以便在网络中传输,并在接收端进行正确的解码过程。文章详细解释了使用Java的URLEncoder.encode()方法进行编码,以及通过URLDecoder.decode()方法进行解码的具体步骤。
2万+

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



