中文乱码问题

中文乱码问题总结:

1.服务器获取jsp传来的中文乱码

new String("你好".getBytes("iso-8859-1"), "UTF-8");  

 

2.jsp显示服务器传来的中文乱码

在Spring3中,@RequesMapping中添加参数 produces = {"application/json;charset=UTF-8"}

如:

@RequestMapping(value = "/xx", produces = {"application/json;charset=UTF-8"})

 

 

 

另一个办法:

JSP中:

xx=encodeURI(encodeURI(s))
服务器: 
xx=URLDecoder. decode(xx, "UTF-8" );
 不用考虑编码问题了。

 

你可能感兴趣的:(中文,Spring3,乱码)