转载自 http://panyongzheng.iteye.com/blog/2222666 谢谢 保留收藏
关于spring java.lang.IllegalArgumentException: Name for argument type [java.lang.String] 的错误 http://blog.csdn.net/liuguanghaoputin/article/details/8695600
Name for argument type [java.lang.String] not available http://m.blog.csdn.net/blog/kouwoo/42869779
SpringMVC强大的数据绑定(2)——第六章 注解式控制器详解——跟着开涛学SpringMVC http://jinnianshilongnian.iteye.com/blog/1705701
为了这个问题费了很大劲,主要参考了了
1.http://stackoverflow.com/questions/2622018/compile-classfile-issue-in-spring-3 这个主要是因为ant编译导致类似的问题。
2. http://stackoverflow.com/questions/10305592/error-class-names-are-only-accepted-if-annotation-processing-is-explicitly-req 一开始src的写法有些问题,改为上面的写法便可。
发现问题:
一次做下载过程中,使用get方式进行下载,
- @ResponseBody
- @RequestMapping(value = "/down/{_listid}/{type}", method = RequestMethod.GET)
- public ResponseEntity<byte[]> download(@PathVariable String _listid, @PathVariable String type) throws IOException {
- ......
- }
在idea和eclipse下面启动工程没问题, 但是部署的时候就出了问题,后台一直提示500错误,但看不到错误细节,后来我直接复制地址,打开标签,直接粘贴url,才看到下面错误:
Error 500: org.springframework.web.util.NestedServletException:
Request processing failed; nested exception is java.lang.IllegalArgumentException:
Name for argument type [java.lang.String] not available, and parameter name information not found in class file either.
原因:
这个错误主要是因为action的参数标注默认是debug级别,比如
- @RequestMapping(value = "/security/login", method = RequestMethod.POST)
- public ModelAndView login(@RequestParam String userName, @RequestParam String password,
- HttpServletRequest request) {
此时userName的级别时debug级别,而在linux下编译时是忽略了这些标注,导致请求时就会找不到userName的参数。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";
- }
写全@PathVariable的参数
- @RequestMapping(value="/users/{userId}/topics/{topicId}")
- public String test(
- @PathVariable(value="userId") int userId,
- @PathVariable(value="topicId") int topicId)
解决方法2:修改build.xml,使用javac debug=true
- <javac srcdir="${src}" destdir="${build}/WEB-INF/classes" debug="true" encoding="utf-8" classpathref="classpath" includeantruntime="on">
- </javac>
相关推荐
在Java编程中,`java.lang.IllegalArgumentException` 是一个标准的运行时异常,它通常表示一个方法接收到的参数值不在预期范围内或者不合法。当尝试将一个无法转换为日期的对象格式化时,就会抛出"Cannot format ...
Exception in thread "main" java.lang.IllegalArgumentException: Not a valid class name: HelloJNIActivity.class ``` 这是因为`javah`命令期望的是类的全名,而不是包含扩展名的文件名。解决方法是只提供类的...
It also covers most of the classes in the main packages (java.lang, java.util, java.io) as implemented in the J2SE™ Development Kit 5.0 (more commonly known as JDK 5.0, or in the older nomenclature ...
在分析和修改源码时,开发者需要具备一定的安卓应用开发知识,包括Java或Kotlin编程语言、Android SDK的使用,以及对Android系统框架的理解。同时,理解MTK的开发工具和API也是必要的,这通常涉及到NDK(Native ...
default argument missing for function name (解决方案).md
TypeError: loop of ufunc does not support argument 0 of type Tensor which has no callable arctan method 报错行 self.u = np.round(np.dot(self.F, self.u)) #或者 self.u = np.round(self.u + np.dot(K, ...
本文将重点介绍一种常见的异常——`java.lang.IllegalArgumentException: argument type mismatch`,并详细解析其成因与解决策略。 #### 异常示例 在JavaWeb项目中使用Struts框架时,可能会遇到如下异常: ```java...
Jad uses JAVA class name as an output file name. For example, if class file 'example1.class' contains JAVA class 'test1' then Jad will create file 'test1.jad' rather than 'example1.jad'. If you want ...
"Python库 | polidoro-py-argument-2.1.0.tar.gz"是一个与Python相关的库,其版本为2.1.0,被打包成tar.gz格式的压缩文件。这个库的名字叫做“polidoro-py-argument”,从名称可以推测它可能专注于处理命令行参数或...
《Spleeter:最佳音轨分离软件的深度解析与应用》 Spleeter,这款被誉为“最好用的音轨分离软件”,是音频处理领域的一颗璀璨明珠。它以其卓越的性能,将音频分类和人声提取提升到了新的高度。...
Overrides the standard java.lang.Object.clone method to return a copy of this cookie. containsHeader(String) - Method in class javax.servlet.http.HttpServletResponseWrapper The default behavior of ...
Java 内功修炼主要涉及了三个关键知识点:静态导入、可变参数以及增强for循环。这些特性都是自Java 5版本引入的,极大地提升了代码的可读性和便捷性。 1. **静态导入(Static Import)** 静态导入是Java 1.5引入的...
3.2.1 Macro argument substitution within strings.....................................................39 3.2.2 Constructing identifier names from macros....................................................
Constructor declaration are just like method declaration, except that they do not have any return type and they use the name of the class. The compiler provides us with a default constructor to the ...
Invalid Command Line Argument(解决方案).md
PEP 3155: Qualified name for classes and functions PEP 412: Key-Sharing Dictionary PEP 362: Function Signature Object PEP 421: Adding sys.implementation SimpleNamespace Using importlib as the ...
Automatic mapping from Java to native functions, with simple mappings for all primitive data types Runs on most platforms which support Java Automatic conversion between C and Java strings, with ...