我正在使用 @RequestParam 注释来获取请求参数,并使用它来将值插入到数据库中。
我已将 Controller 设置为重定向到包含文本字段的同一页面,供用户输入值,这些值正在使用 @RequestParam 注释读取。
但是在我在文本字段中输入值并单击提交后,它会引发此错误
Request processing failed; nested exception is java.lang.IllegalArgumentException: Name for argument type [java.lang.String] not available, and parameter name information not found in class file either.
我是 Spring 3 的新手,无法理解错误。任何人都可以阐明这一点。
提前致谢,
维韦克
最佳答案
为了将请求参数的值注入(inject)您的处理程序方法参数,应满足以下任一条件
例如
下面将把名为“studentName”的请求参数注入(inject)到方法参数studentName中
public String goToStep(@RequestParam String studentName)
public String goToStep(@RequestParam("nameOfStudent") String studentName)
如果您的问题仍然存在,请发布您的处理程序方法代码。
关于spring - 在 Spring 3 中使用 @RequestParam 会引发错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7484659/