java - In Spring MVC using jquery ajax with json, getting error : "unsupported media type" -


I am creating a Spring MVC application, in JSP I need to send the object to the controller and then return the object to jsp have to give. But I'm getting an "unsupported media type" error. Can someone help me? Below is my code:

** In Administrator:

  @RequestMapping (value = "/ addPerson", method = RequestMethod.POST, header = {"content-type = App / Jason "}) @ ResponseBodybody Public Ains Edson (@RequestBody person) {System.out.println (person.getName ()); Return person; }  

** In JSP:

  $ .ajax ({type: "POST", url: "addPerson.view", data: JSON Encrypt ({name: "Adam", age: 30, city: "Paris"}), type of content: 'app / jason', success: function (data) {alerts (data. Name + "has been added") ;}, Error: Work (Excerpt, Error Type, Exception) {var errorMessage = exception  

Try it out:

@RequestMapping (value = "/ AddPerson ", method = RequestMethod.POST, consumes = {" application / json "})


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -