`
colky
  • 浏览: 23453 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

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

    博客分类:
  • JAVA
 
阅读更多

 

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.HandlerMethodInvocationException
2011-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>



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics