解决乱码的问题

来源:互联网 发布:淘宝购买dota2饰品 编辑:程序博客网 时间:2024/04/25 17:06

场合:页面本身有中文的时候

解决办法:servletresp.setContentType("text/html;charset=gbk");

Jsp: <%@ page contentType="text/html;charset=gb2312"%>

注意:一定要写在PrintWriter out = resp.getWriter();之前

 

场合:解决get方式乱码问题:

解决办法:修改server.xml àURIEncoding="GBK"

 

场合:解决post方式提交内容的乱码

解决办法:request.setCharacterEncoding("GBK");

注意:一定要写在存取第一个参数之前   

不要调用response.setCharacterEncoding("GBK");

 

场合:<jsp:param name="user" value="<%=s%>"/>url地址包含中文参数

解决办法:<%request.setCharacterEncoding("GBK");%>

注意:

有意者加群:108732902

原创粉丝点击