首页 > Web开发 > 详细

jsp传入servlet出现乱码

时间:2020-05-26 21:55:53      阅读:46      评论:0      收藏:0      [点我收藏+]

post方法

request.setCharacterEncoding("UTF-8");//传值编码
response.setContentType("text/html;charset=UTF-8");//设置传输编码

 

get方法

1、  String username=request.getParameter("username");
        String username1=new String(username.getBytes("ISO-8859-1"),"utf-8");

2、在tomcat服务器中修改server.xml:URIEncoding="utf-8",因为在Tomcat5.0中和以后,默认情况下使用ISO-8859-1对URL提交的数据和表单中GET方式提交的数据进行重新编码。

3、

  浏览器中两次URL编码。

  服务器中自己再做一次URL解码。

 

jsp传入servlet出现乱码

原文:https://www.cnblogs.com/XYJ-MK/p/12968470.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!