title: How to test POST spring mvc
body: <p>My problem is to how to call this. I could do </p>
  
  <pre><code>MyObject o = new MyObject();
  myController.save(o, "value");
  </code></pre>
  
  <p>but this is not what I would like to do. I would like the MyObject to be in the request post body? How can this be done?</p>
  
  <pre><code>@Requestmapping(value="/save/{value}", method=RequestMethod.POST)
  public void post(@Valid MyObject o, @PathVariable String value{
      objectService.save(o);
  }
  </code></pre>
  
  <p>Just to be clear I am talking about unit testing.</p>
  
  <p>Edit:</p>
  
  <pre><code>@RequestMapping(value = "/", method = RequestMethod.POST)
  public View postUser(ModelMap data, @Valid Profile profile, BindingResult bindingResult) {
  
      if (bindingResult.hasErrors()) {
  
          return dummyDataView;
      }
  
  
      data.put(DummyDataView.DATA_TO_SEND, "users/user-1.json");
      profileService.save(profile);
      return dummyDataView;
  }
  </code></pre>