话不多说,直接粘代码
发送方
UrlParaCode.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%> <html> <head> <title>My JSP ‘UrlParaCode.jsp‘ starting page</title> </head> <body> <% String UrlPara="王屯屯"; %> <a href="UrlParaCodeAfter.jsp?UrlPara=<%=UrlPara %>">这是一个url带有中文参数</a> </body> </html>
UrlParaCodeAfter.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%> <html> <head> <title>My JSP ‘ButttonUrlParaCodeAfetr.jsp‘ starting page</title> </head> <body> <% request.setCharacterEncoding("GBK"); response.setCharacterEncoding("GBK"); String UrlPara=request.getParameter("UrlPara"); String DecodePara = new String(UrlPara.getBytes("ISO-8859-1"), "GBK"); out.println("UrlPara"+UrlPara); out.println("DecodePara"+DecodePara); %> </body> </html>
java的url有中文参数导致乱码,布布扣,bubuko.com
原文:http://blog.csdn.net/tuntunwang/article/details/25456887