get/post 提交乱码问题解决(未使用过滤器)——Servlet解决


前提:HttpServletRequest request

/**
* post提交参数

 */

request.setCharacterEncoding("utf-8");

/**
 * 对get提交参数处理

 */

// 1)得到原来的参数
String value = request.getParameter(name); // iso-8859-1
// 2)手动解码
if ("GET".equals(request.getMethod())) {

value = new String(value.getBytes("iso-8859-1"), "utf-8");
}

猜你喜欢

转载自blog.csdn.net/m0_37461645/article/details/78993643