SpringMVC is not recognizing request body parameters if using PUT

后端 未结 4 1121
我在风中等你
我在风中等你 2020-12-04 16:50

Maybe this is supposed to not work, but at least I\'d like to understand why then. I am passing a simple val=somevalue in the PUT body but spring sends back a <

4条回答
  •  盖世英雄少女心
    2020-12-04 17:32

    I don't know of a work around at this point, but here is the bug report that is a "Won't Fix." I've been fighting the same issue

    https://jira.springsource.org/browse/SPR-7414

    Update: Here is my fix. I'm using RequestBody annotation. Then using MultiValueMap.

    http://static.springsource.org/spring/docs/3.0.5.RELEASE/reference/mvc.html#mvc-ann-requestbody

    @RequestMapping(value = "/{tc}", method = RequestMethod.PUT) 
    public void update(@PathVariable("tc") final String tc, 
    @RequestBody MultiValueMap body, HttpServletResponse response) {
    
        String name = body.getFirst("name");
    // more code
    }
    

提交回复
热议问题