I have about fifty controllers that use @ResponseBody annotation.
Like this:
@RequestMapping(value = "/someUrl.controller", method = RequestMethod.GET)
public @ResponseBody Object getObject(@RequestParam("id") Long id) {
Object object = provider.getObject(id);
return object;
}
Some times getObject method return null
. The issues is that on client side I get empty response instead of null
.
In the initial implementation we have custom JsonView
object that works as wrapper without @ResponseBody annotation.
Like this:
@RequestMapping(value = "/someUrl.controller", method = RequestMethod.GET)
public JsonView<Object> getObject(@RequestParam("id") Long id) {
Object object = provider.getObject(id);
return new JsonView(object);
}
So it was working fine.
I have found some solution at How do you override the null serializer in Jackson 2.0? but unfortunatly it works only for fields in the POJOs.
Have you any ideas how in it can be handled?
Thanks in advance!