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

c++ - C/pp Sockets, recv()/send() works only under gdb -

GO: Serve static pages -

objective c - How to open front/back camera at the same time in iOS developing? -