首页 > 技术文章 > 原创:如何解决 传中文参数 显示乱码问题

kuiyeit 2015-09-09 17:53 原文

前台:

 1 <script type="text/javascript">
 2   $(document).ready(function(){
 3      $("#postButton").click(fuction(){
 4      var city="深圳市";  city=UrlEncode(city);//前台用js对中文进行一次编码
 5      $.ajax({
 6         type:"GET",
 7         url:root+"/getCity.htm",
 8         data:city,
 9         dataType:"html",
10         success: function(data){
11         alert("后台to前台:"+data);
12        }
13 });
14 
15 });
16 });
17 </script>

后台:

public String getCity(){
String city=request.getParameter("city");
city=UrlDecoder.decode(city,"utf-8");//后台手动进行一次解码。
getResponse().getWriter().print("后台收到的城市名:"+city);
return null;
}

 更多:http://blog.csdn.net/xligan/article/details/4965966

推荐阅读