codeworm

导航

 

3.对于convert,有个缺陷是:
    对于
    @RequestMapping(value="addTobacco",method = RequestMethod.POST, consumes = "application/json",produces="text/html")
    public @ResponseBody List<Tobacco> saveTobacco(@RequestBody Tobacco tobacco) {}
    如果用JSON请求,要求用HTML响应,就会406
    如果用HTML请求,要求用JSON响应,就会302 TODO 待验证
    @RequestMapping(value="addTobacco",method = RequestMethod.POST, consumes = "application/json",produces="text/html")
    public @ResponseBody List<Tobacco> saveTobacco(@RequestBody Tobacco tobacco) {}
    如果用JSON请求,要求用JSON相应,就会:415 The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.
    正确的方式:
    json的返回json
    html的返回html
    协议必然是对等的

posted on 2015-10-03 09:40  codeworm  阅读(122)  评论(0)    收藏  举报