方法1:
url="xxx.jsp?id="+java.net.URLEncoder.encode("中文", "UTF-8") 在这里,我们要用java.net.URLEncoder.encode("中文", "UTF-8") 接收时,我们用 String inf=request.getParameter("id"); inf= new String(inf.getBytes("iso-8859-1"),"UTF-8");
方法2:
js var title = document.getElementById("title"); var url = "xxx.jsp?title="+encodeURI(title.value); jsp String title = new String(request.getParameter("qTitle").getBytes("iso-8859-1"),"UTF-8");
本文介绍了两种在前端和后端之间传递中文参数的方法。一种是使用Java的URLEncoder进行编码,并在接收时进行相应的解码;另一种是利用JavaScript的encodeURI方法编码,再在后端通过指定的字符集进行解码。
2031

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



