java - Spring 4.3.10 controller throws Http 400 (Bad Request) whereas Spring 3.1.1 works just fine -


we have legacy code running spring 3.1.1. controller looks this:

@requestmapping(value = "/model/save", method = { requestmethod.get, requestmethod.post }, headers = "accept=application/json; charset=utf-8") @responsebody public responsedto save(@requestbody jsonnode jsonproperty,  httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {      myobject myobject = new objectmapper().readvalue(jsonproperty, myobject.class);      // save myobject here      ...  } 

right now, controller works expected.

i'm in process of upgrading spring 4.3.10. part of task, have latest spring jars , corresponding jackson jars in classpath. time, http 400 (bad request) error.

just looking @ legacy code, realized reading jsonnode request body , mapping model saved. changed code this:

@requestmapping(value = "/model/save", method = { requestmethod.get, requestmethod.post }, headers = "accept=application/json; charset=utf-8") @responsebody public responsedto save(@requestbody myobject myobject,  httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {     // save myobject here     ...  } 

this change works perfect. have 2 questions:

  1. is legacy code following proper coding standards?
  2. why legacy code (spring 3.1.1) not work in latest spring (4.3.10)?


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -