Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring MVC JSON - POST Mapping perfect untill...then 415 Unsupported Media
    primarykey
    data
    text
    <p>I have a controller method that looks like this:</p> <pre><code>@RequestMapping(value = "{userId}", method = RequestMethod.POST) public @ResponseBody Map save( @PathVariable Long userId,@RequestBody MealPlan mealPlan) { //do work } </code></pre> <p>Jackson was mapping my POSTs perfectly until I added the following to MealPlan:</p> <pre><code>@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinTable(name = "Meal_Plan_Meals", joinColumns = { @JoinColumn(name = "mealPlan_id")}, inverseJoinColumns = { @JoinColumn(name = "meal_id")}) public Set&lt;Meal&gt; getMeals() { return meals; } </code></pre> <p>I have two other Sets in the same class mapped in the same way and those work fine. </p> <p>The headers are all good in the request (as i said it works fine until I add this Set). </p> <p>Any thoughts on what I am doing wrong would be very much appreciated.</p> <p>Thanks, Bruce</p> <pre><code>INFO: 14:20:20.641 [http-thread-pool-8080(5)] DEBUG o.s.web.servlet.DispatcherServlet - DispatcherServlet with name 'mvc-dispatcher' processing POST request for [/mealplanner/api/mealplan/1] INFO: 14:20:20.642 [http-thread-pool-8080(5)] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path /mealplan/1 INFO: 14:20:20.643 [http-thread-pool-8080(5)] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Returning handler method [public java.util.Map com.enthrive.api.controller.MealPlanController.save(java.lang.Long,com.enthrive.domain.mealplanner.MealPlan)] INFO: 14:20:20.643 [http-thread-pool-8080(5)] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'mealPlanController' INFO: 14:20:20.709 [http-thread-pool-8080(5)] DEBUG o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver - Resolving exception from handler [public java.util.Map com.enthrive.api.controller.MealPlanController.save(java.lang.Long,com.enthrive.domain.mealplanner.MealPlan)]: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=utf-8' not supported INFO: 14:20:20.713 [http-thread-pool-8080(5)] DEBUG o.s.w.s.m.a.ResponseStatusExceptionResolver - Resolving exception from handler [public java.util.Map com.enthrive.api.controller.MealPlanController.save(java.lang.Long,com.enthrive.domain.mealplanner.MealPlan)]: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=utf-8' not supported INFO: 14:20:20.713 [http-thread-pool-8080(5)] DEBUG o.s.w.s.m.s.DefaultHandlerExceptionResolver - Resolving exception from handler [public java.util.Map com.enthrive.api.controller.MealPlanController.save(java.lang.Long,com.enthrive.domain.mealplanner.MealPlan)]: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=utf-8' not supported INFO: 14:20:20.714 [http-thread-pool-8080(5)] DEBUG o.s.web.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'mvc-dispatcher': assuming HandlerAdapter completed request handling INFO: 14:20:20.714 [http-thread-pool-8080(5)] DEBUG o.s.web.servlet.DispatcherServlet - Successfully completed request </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload