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 = "/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

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.

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest