读书人

Ant编译的项目出现HandlerMethodInv

发布时间: 2012-07-15 20:20:06 作者: rapoo

Ant编译的项目,出现HandlerMethodInvocationException错误

?

Ant编译项目运行出错:
2011-09-21 09:47:43,485 INFO ?[STDOUT] 2011-09-21 09:47:43,466 [http-0.0.0.0-18080-9] WARN ?com.infindo.appcreate.servlet.ExceptionHandler - Handle exception: org.springframework.web.bind.annotation.support.HandlerMethodInvocationException2011-09-21 09:47:43,489 ERROR [STDERR] org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public java.lang.String com.infindo.appcreate.action.front.FrontController.login(java.lang.String,java.lang.String,org.springframework.ui.ModelMap,org.springframework.web.bind.support.SessionStatus)]; 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.
该错误是因为如下原因引起的:?(引用 http://bigcat.easymorse.com/?p=472%0A)在使用SpringMVC绑定基本类型(如String,Integer等)参数时,应通过@RequestParam注解指定具体的参数名称,否则,当源代码在非debug模式下编译后,运行时会引发HandlerMethodInvocationException异常,这是因为只有在debug模式下编译,其参数名称才存储在编译好的代码中。
解决办法有2个1.?添加@RequestParam注解,代码如下:public void findsessions(HttpServletRequest request, ModelMap modelMap,HttpServletResponse response,@RequestParam String keys) { ……}
2. ant编译时以debug模式编译,脚本中增加?debug="true"

? ? ? ??<javac?

?? ? ? ? ? ? srcdir="${src.default}"

?? ? ? ? ? ? destdir="${project.dist.classes}"

?? ? ? ? ? ? debug="true"

?? ? ? ? ? ? deprecation="${compile.deprecation}"

?? ? ? ? ? ? optimize="${compile.optimize}"

?? ? ? ? ? ? verbose="${javac.verbose}"

?? ? ? ? ? ? fork="${javac.fork}" source="1.6" encoding="UTF-8">

? ? ? ? ? ? <classpath refid="project.classpath"/>

?

? ? ? ? </javac>



读书人网 >开源软件

热点推荐