UNCODE / espace特殊字符JSON DATA Spring MVC

时间:2015-05-10 13:20:44

标签: java json spring web-services

我们使用Ajax从UI发送JSON数据:

$.ajax({ 
      url: "/RegisterUser", 
      type: "POST",
      Contenttype: "application/json; charset=utf-8",
      dataType: "json", 
      data: JSON.stringify(formData), 
      success: function(data, textStatus, xhr) 
               { 
                  alert(data);
               }



       }); 


@RequestMapping(value="/RegisterUser", method = RequestMethod.POST)
public ServiceResponse registerUser(
        @RequestBody String UserDetails) {

    logger.info("JSON DATA"+UserDetails);

}

但是,来自webservice的数据带有特殊字符,如何处理??

%7B%22Test%22%3A%7B%22Test11%22%3A%22Test%22%2C%22name%22%3A%22Test11%22%2C%22email%22%3A%22Test%40gmail.com%22%7D%2C%22Details%22%3A%7B%22date_of_brith%22%3A%2205%2F01%2F2015%22%2C%22gender%22%3A%22Male%22%2C%22

如何解码/转义数据到String?

1 个答案:

答案 0 :(得分:0)

看起来像readUIntLE(position, 3)数据。

尝试并使用:

application/x-www-form-urlencoded