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



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值