response流转页面传递中文参数值乱码解决

 

httpServletResponse.sendRedirect("/Action.do?action=search&name=方便面");

String name = httpServletRequest.getParameter("name");

 

name为乱码.

 

解决办法为使用java.net.URLEncode进行转换:

 

httpServletResponse.sendRedirect("/Action.do?action=search&name=" + URLEncoder.encode("方便面","gbk");

你可能感兴趣的:(java,.net)