Name for argument type [java.lang.String] not available

来源:互联网 发布:江苏省vb全称 编辑:程序博客网 时间:2024/05/22 07:58

今天把项目打包,运行的时候报了如下的异常:

java.lang.IllegalArgumentException: Name for argument type [java.lang.String] not available, and parameter name information not found in class file either.org.springframework.util.Assert.notNull(Assert.java:112)org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.updateNamedValueInfo(AbstractNamedValueMethodArgumentResolver.java:144)org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.getNamedValueInfo(AbstractNamedValueMethodArgumentResolver.java:123)org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:84)org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:77)org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:162)org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:123)org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)javax.servlet.http.HttpServlet.service(HttpServlet.java:621)org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)javax.servlet.http.HttpServlet.service(HttpServlet.java:728)net.spring.web.XssFilter.doFilter(Unknown Source)

原因分析:

因为我在请求的方法里,需要传入一个参数

@RequestMapping("hello")public String helloWorld(Map<String, Object> map, HttpServletRequest request,@RequestParam(required = false) String hhh) {System.out.println("hello");System.out.println("["+hhh+"]");map.put("message", "test message111");return "helloView";}

从网上找到解决的方法:http://blueram.iteye.com/blog/1921693

eclipse默认是debug级别的函数里面的参数名保留,但是ant编译就不行了。

解决方法1:写全@RequestParam的参数

@RequestMapping("hello")public String helloWorld(Map<String, Object> map, HttpServletRequest request,@RequestParam(value="hhh", required = false) String hhh) {System.out.println("hello");System.out.println("["+hhh+"]");map.put("message", "test message111");return "helloView";}

解决方法2:修改build.xml,使用javac  debug=true

<javac srcdir="${src}" destdir="${build}/WEB-INF/classes" debug="true" encoding="utf-8" classpathref="classpath" includeantruntime="on"></javac>

最后需要把先stop tomcate,然后把Tomcat 7.0\webapps下的项目文件夹删除,然后再start tomcat,这样问题就解决了。

在eclipse开发的时候,自动编译的情况下也会出现这样的问题,是因为自动编译的设置问题,如下:


0 0
原创粉丝点击