Use @RequestBody with optional body in latest Spring v4
You can use java.util.Optional
:
@RequestMapping(value="/add/employee", method=RequestMethod.POST)
public void addEmployee(@RequestBody Optional<Employee> employee){
// ...
}
@Santosh, I'm not sure which required argument you're referring. Mike already mentioned that he tried using @RequestBody (required=false)
and request was still null. May be you can elaborate more & give example.
@Mike, probably you can try to have another separate converter that will serve your purpose.
Note: I noticed same issue with Spring v4.1.6 & Mike could be using that as he mentioned he is using latest version.