I have write in my Spring @controller this mapping of request, it accepts request and parameter "tipoLista,numPagina"

 @RequestMapping(value = "/admin/evento/approvatutti", params = "{tipoLista,numPagina}", method = RequestMethod.GET) public ModelAndView approvaTuttiGliEventi(@RequestParam("tipoLista") String tipoLista, @RequestParam("numPagina") String numPagina, ModelAndView model) { ....bla bla ...bla... } 

When i call localhost:8084/context/admin/evento/approvatutti?tipoLista=valueOfParameter&numPagina=0

I received error code 400, bad request. I have enabled TRACE level logging and I receive this message:

Resolving exception from handler [null]: org.springframework.web.bind.UnsatisfiedServletRequestParameterException: Parameter conditions "{tipoLista,numPagina}" not met for actual request parameters: tipoLista={approvabili}, numPagina={0} DEBUG - nseStatusExceptionResolver - Resolving exception from handler [null]: org.springframework.web.bind.UnsatisfiedServletRequestParameterException: Parameter conditions "{tipoLista,numPagina}" not met for actual request parameters: tipoLista={approvabili}, numPagina={0} DEBUG - ltHandlerExceptionResolver - Resolving exception from handler [null]: org.springframework.web.bind.UnsatisfiedServletRequestParameterException: Parameter conditions "{tipoLista,numPagina}" not met for actual request parameters: tipoLista={approvabili}, numPagina={0} 

1 Answer

The params attribute of @RequestMapping expects a String[] with

Same format for any environment: a sequence of "myParam=myValue" style expressions

So each String in the array is of the format

paramName=paramValue 

but you can omit the =paramValue. But you are providing a single String value like

{tipoLista,numPagina} 

this would mean the request query string would have to look like

?{tipoLista,numPagina}=someValue 

which obviously makes no sense and Spring complains

Resolving exception from handler [null]: org.springframework.web.bind.UnsatisfiedServletRequestParameterException: Parameter conditions "{tipoLista,numPagina}" not met for actual request parameters: tipoLista={approvabili}, numPagina={0} 

Instead, you can change it to

params = {"tipoLista","numPagina"} 

but this is not necessary. Get rid of the params attribute all together. You already have @RequestParam parameters in your method which are required.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.