spring can't instantiate UriInfo in rest service

后端 未结 1 1753
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-24 13:20

I try to use UriInfo to get the list of request parameters, here is my code :

@RestController public class MyController {
@RequestMapping(value = \"/documents\"         


        
相关标签:
1条回答
  • 2021-01-24 13:45

    It's because UriInfo isn't a Spring MVC object. It is a JAX-RS object and you are not using JAX-RS, you're using Spring MVC. With Spring MVC, if you just want the parameter map, you can just inject it with @RequestParam

    public Object getDocuments(@RequestParam MultiValueMap<String, String> requestParams)
    

    Note, the MultiValueMap is a Spring class, it's not the JAX-RS MultivaluedMap.

    See also:

    • Spring MVC - How to get all request params in a map in Spring controller?
    0 讨论(0)
提交回复
热议问题