Announcement Announcement Module
No announcement yet.
MVC method argument populated when using spring-test and Jetty, but not Tomcat Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • MVC method argument populated when using spring-test and Jetty, but not Tomcat

    I have a method that looks similar to:

    @RequestMapping(value = "/lists/{listid}/items/{itemid}", method = PUT)
        Item updateItem(
                @PathVariable String listid,
                @PathVariable String itemid,
                @ModelAttribute UpdateItemData updateItemData
        ) throws AjaxException {
            Item toUpdate = itemService.find(itemid);
            Item updated = itemService.update(toUpdate, updateItemData);
            return updated;
    When running tests using params that match up with the fields for UpdateItemData the fields of updateItemData are populated and the tests pass. Likewise in Jetty. So, up until now it appeared to work fine and I had assumed that Spring was doing the mapping work for me and life was good.

    However, I recently started doing Tomcat deployments and in Tomcat this doesn't work at all. The fields in the object will always be null regardless of what params I PUT.

    What is the expected behaviour? And why is the behaviour in test and in jetty different from that in Tomcat? Is there some other configuration I should be doing?

    edit: Can anyone confirm if this is the cause of what I've described above:
    RequestMapping PUT method does not have any populate any parameters

    Many thanks,
    Last edited by matt.friedman; Mar 16th, 2013, 11:19 AM. Reason: add bug report for reference

  • #2
    For PUT to work you have to use the filter mentioned in the bug report (the HttpPutFormContentFilter).

    PUT isn't clearly defined on how to behave/handle parts of the request and apparently Jetty choose to implement it different from Tomcat... Different servers can implement it differently (I suggest a read of the javadoc of the given filter).


    • #3
      This works perfectly. Thanks for the assistance.