I am developing a Spring Rest application. One of my methods is that:
@RequestMapping(method = RequestMethod.GET)
public @ResponseBody
Collection<Configuration> getConfigurationInJSON() {
Collection<Configuration> confList = new ArrayList<Configuration>();
...
I fill my confList and send it for GET request, it works. However when I want to keep that confList in a HashMap and send it after got it’s entrySet as like that:
@RequestMapping(method = RequestMethod.GET)
public
@ResponseBody
Collection<Configuration> getAllConfigurationsInJSON() {
return configurationMap.values();
}
It gives me 406 error, so it means there is a wrong. What are the differences between that collections and why the second one is not same with first example?
For the sake of simplicity, can you just copy the
values()collection?Only thing that comes to my mind is that Spring expects mutable collection, but don’t really understand why. Hard to say without debugging, try enabling
org.springframework.webfull logging.