jsp使用request获取post传递来的参数时出现中文乱码

来源:互联网 发布:阿里云华南 编辑:程序博客网 时间:2024/05/18 19:44

问题截图


问题代码

<form method="post" action="result.jsp"><input type="text" name="name"><input type="submit" value="提交"></form>

<%//request.setCharacterEncoding("UTF-8");String name = request.getParameter("name");session.setAttribute("name", name);%>名字是:<%= name %>

解决方法

在使用request获取参数值之前,设置编码
request.setCharacterEncoding("UTF-8");
阅读全文
0 0