首页 > Web开发 > 详细

JSP表单提交中文乱码解决方案

时间:2016-08-07 18:33:38      阅读:186      评论:0      收藏:0      [点我收藏+]

分2种提交方式,解决方案不同:

1、form表单提交方式为get

技术分享

乱码:

技术分享

解决方案:

第1种方法:tomcat-config-sever.xml 

技术分享

第2种方法:

<%
String username = request.getParameter("username");
String name = new String(username.getBytes("ios-8859-1"),"utf-8");

String password = request.getParameter("password");
out.print("--用户名是:"+name+"--密码是:"+password);
%>

 

2、form表单提交方式为post

直接在b.jsp中加入:

<%
    request.setCharacterEncoding("utf-8");
    String username = request.getParameter("username");
    //String name = new String(username.getBytes("ios-8859-1"),"utf-8");
    
    String password = request.getParameter("password");
    out.print("--用户名是:"+username+"--密码是:"+password);
 %>

 

JSP表单提交中文乱码解决方案

原文:http://www.cnblogs.com/sincoolvip/p/5746678.html

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