Using @RequestParam causes an error in Spring 3

I use the @RequestParam annotation to get query parameters and use them to insert values ​​into the database. I installed a controller to redirect to the same page that contains text fields for the user to enter values ​​that are read using the @RequestParam annotation.

But after I enter the values ​​in the text fields and click "Submit", it gives this error

Request processing error; The nested exception is java.lang.IllegalArgumentException: the argument type name [java.lang.String] is not available, and parameter name information is also not found in the class file.

I am new to Spring 3 and cannot understand the error. Someone can shed light on the same thing.

Thanks in advance, Vivec

+5
source share
2 answers

To enter the value of the query parameter into the parameter of the handler method, either one of the following must be executed:

  • The name of the request parameter must match the name of the method parameter. For example, After that, in the parameter of the studentName method

    a query parameter named "studentName" will be entered

    public String goToStep(@RequestParam String studentName)

  • The request parameter name must be explicitly specified if it does not match the method parameter. The following will introduce the requestname parameter "nameOfStudent" into studentName:

    public String goToStep(@RequestParam("nameOfStudent") String studentName)

Please post the handler method code if the problem persists.

+8
source

, , . Spring 3.1.0.M2, , @PathVariable - @Controller.

. 3.0.6 3.1.0.BUILD-SNAPSHOT. , .

+3

All Articles