When using the SPRINGMVC binding base type (such as String,integer, etc.) parameters, specify the specific parameter name through the @requestparam annotation, otherwise, when the source code is compiled in non-debug mode, The runtime throws a Handlermethodinvocationexception exception because the parameter name is stored in the compiled code only if it is compiled in debug mode.
For example, the following code throws an exception:
@RequestMapping (value = "/security/login", method = requestmethod.post) public modelandview login (@RequestParam String UserName, @RequestParam String password, httpservletrequest request) {.............
Org.springframework.web.util.NestedServletException:Request processing failed; Nested exception is org.springframework.web.bind.annotation.support.HandlerMethodInvocationException:
Failed to invoke handler method [public Org.springframework.web.servlet.ModelAndView Com.mypackage.security.controller.LoginController.login (Java.lang.string,java.lang.string, Javax.servlet.http.HttpServletRequest)]; Nested exception is java.lang.IllegalStateException:No parameter name specified for argument of type [java.lang.String], and no parameter name information found in class file either.
Org.springframework.web.servlet.FrameworkServlet.processRequest (frameworkservlet.java:659)
..........
Org.springframework.web.bind.annotation.support.HandlerMethodInvocationException:Failed to invoke Handler method [ Public Org.springframework.web.servlet.ModelAndView Com.mypackage.security.controller.LoginController.login ( Java.lang.string,java.lang.string,javax.servlet.http.httpservletrequest)]; Nested exception is java.lang.IllegalStateException:No parameter name specified for argument of type [java.lang.String], and no parameter name information found in class file either.
Org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod ( handlermethodinvoker.java:171)
..........
Java.lang.IllegalStateException:No parameter name specified for argument of type [java.lang.String], and No parameter Nam E information found in class file either.
Org.springframework.web.bind.annotation.support.HandlerMethodInvoker.getRequiredParameterName ( handlermethodinvoker.java:618)
..........
Java code
@RequestMapping (value = "/security/login", method = Requestmethod.post)
Public Modelandview Login (@RequestParam ("UserName") String UserName, @RequestParam ("password") String password, httpservletrequest request) {
......................
Spring MVC Report Exception: Org.springframework.web.util.NestedServletException:Request processing failed