Unsatisfiedservletrequestparameterexception Spring Controller Don't Mapping Request, Error 400
I Have Write in My Spring @Controller This Mapping of Request, It Accepts Request and Parameter "Tipolista, numPagina" @Requestmapping(Value =...
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.