使用REST服务增加数据,中文出现乱码问题,可以选择将数据用问题传值法的方式以URL的字符串作为Requst对象传递至后台!
public String saveSystemNotice(@Context HttpServletRequest request) throws Exception{
String str = (String)request.getParameter("str");//request.getAttribute("name");
str= new String(str.getBytes("UTF-8"), "GBK");
String strs=java.net.URLDecoder.decode(str,"UTF-8");
try {
this.mobileBusinessService.saveSystemNotice(strs);
return "<xml><result>ok</result></xml>";
} catch (Exception e) {
return"<xml><result>no</result></xml>";
}
public String saveSystemNotice(@Context HttpServletRequest request) throws Exception{
String str = (String)request.getParameter("str");//request.getAttribute("name");
str= new String(str.getBytes("UTF-8"), "GBK");
String strs=java.net.URLDecoder.decode(str,"UTF-8");
try {
this.mobileBusinessService.saveSystemNotice(strs);
return "<xml><result>ok</result></xml>";
} catch (Exception e) {
return"<xml><result>no</result></xml>";
}