Avoir cette définition de point final:ImmutableSet dans le point final GET de printemps avec AngularJS
@RequestMapping(value = "/foo_resource", method = RequestMethod.GET)
public FooResponse retrieveFoo(
@RequestParam("the_param") ImmutableSet<String> params,
@RequestParam(name = "include_all", defaultValue = "true") boolean includeAll) {
return aService.retrieveFoo(params, includeAll);
}
Je voudrais que mon contrôleur AngularJS envoyer les params, cependant, je bout en obtenir toujours la même erreur:
Caused by: org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@org.springframework.web.bind.annotation.RequestParam com.google.common.collect.ImmutableSet<java.lang.String>] for value '"valuez"'; nested exception is java.lang.IllegalArgumentException: Could not instantiate Collection type: com.google.common.collect.ImmutableSet
at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:43)
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:203)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:173)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:108)
at org.springframework.beans.TypeConverterSupport.doConvert(TypeConverterSupport.java:64)
at org.springframework.beans.TypeConverterSupport.convertIfNecessary(TypeConverterSupport.java:47)
at org.springframework.validation.DataBinder.convertIfNecessary(DataBinder.java:713)
at org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:120)
... 111 common frames omitted
Caused by: java.lang.IllegalArgumentException: Could not instantiate Collection type: com.google.common.collect.ImmutableSet
at org.springframework.core.CollectionFactory.createCollection(CollectionFactory.java:206)
at org.springframework.core.convert.support.StringToCollectionConverter.convert(StringToCollectionConverter.java:68)
at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:37)
... 118 common frames omitted
côté angulaire, j'ai bien sûr essayé plusieurs options telles que:
$http.get('xxx/foo_resource', {
params: { 'the_param': JSON.stringify('valuez')}
})
ou:
$http.get('xxx/foo_resource', {
params: { 'the_param[]': 'valuez'}
})
ou:
$http.get('xxx/foo_resource', {
params: { 'the_param': ['valuez']}
})
... etc. Est-ce que cette goyave est liée? Puis-je utiliser des collections immuables à cette fin? Ou est-ce que je ne vois pas quelque chose?
BTW, j'utilise Java 8, AngularJS 1.6, Spring Boot 1.5.6, goyave 22,0