Spring MVC数据绑定为请求串

POST请求调用SpringMVC的控制方法,URL后面跟有请求串同时请求体里面有数据

        @RequestMapping(value = "xxxxx", method = RequestMethod.POST)

@ResponseBody

public BaseRespEntity xxxxx(@RequestBody String jsonText, HttpServletRequest request)

调用之前需要对请求头进行设置,需要将content-type设置为application/json,如果不设置的话,会将请求串绑定到jsonText中,导致后面的出现数据异常。

猜你喜欢

转载自pangadam.iteye.com/blog/2358947
今日推荐