记一次SpringMVC碰到的坑
java.lang.IllegalArgumentException:
Name for argument type [java.lang.String] not available,
and parameter name information not found in class file either.
java.lang.IllegalArgumentException:
Name for argument type [java.lang.String] not available,
and parameter name information not found in class file either.
一、解决方案一
- (1)报错的测试代码,方法形参上没有用@RequestParam注解
@RequestMapping(value = "/mytest" ,produces="text/html;charset=UTF-8" )
@ResponseBody
public String testRequestPara(String name,String password){
System.out.println(name);
return name + "--" + password;
}
@RequestMapping(value = "/mytest" ,produces="text/html;charset=UTF-8" )
@ResponseBody
public String testRequestPara(String name,String password){
System.out.println(name);
return name + "--" + password;
}
- (2)修改后正常运行的测试代码
@RequestMapping(value = "/mytest" ,produces="text/html;charset=UTF-8" )
@ResponseBody
public String testRequestPara(@RequestParam("name") String name,
@RequestParam("password") String password){
System.out.println(name);
return name + "--" + password;
}
@RequestMapping(value = "/mytest" ,produces="text/html;charset=UTF-8" )
@ResponseBody
public String testRequestPara(@RequestParam("name") String name,
@RequestParam("password") String password){
System.out.println(name);
return name + "--" + password;
}

- (3)小结
- <1> 解决方案其实就是在参数前面加了个@RequestParam注解,并在注解中指定了参数的名字。
- <2> 在后续开发的过程,每次都加那个注解,防止项目上线就出问题
二、自己研究出来的解决方案
- (1)解决的过程


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<debug>false</debug>
<!-- 加入编译参数 -->
<compilerArgument>-g</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<debug>false</debug>
<!-- 加入编译参数 -->
<compilerArgument>-g</compilerArgument>
</configuration>
</plugin>
- (2)问题的深入分析

debug boolean 2.0 Set to true to include debugging information in the compiled class files.
Default value is: true.
User property is: maven.compiler.debug.
debuglevel String 2.1 Keyword list to be appended to the -g command-line switch.
Legal values are none or a comma-separated list of the following keywords: lines,vars, and source.
If debug level is not specified, by default, nothing will be appended to -g.
If debug is not turned on, this attribute will be ignored.
User property is: maven.compiler.debuglevel.
debug boolean 2.0 Set to true to include debugging information in the compiled class files.
Default value is: true.
User property is: maven.compiler.debug.
debuglevel String 2.1 Keyword list to be appended to the -g command-line switch.
Legal values are none or a comma-separated list of the following keywords: lines,vars, and source.
If debug level is not specified, by default, nothing will be appended to -g.
If debug is not turned on, this attribute will be ignored.
User property is: maven.compiler.debuglevel.
将布尔设置为true,将调试信息包含在已编译的类文件中。
默认值是:true。
用户属性是:maven.编译。调试。
在-g命令行开关中附加的调试级字符串关键字列表。
法律值不是一个或一个逗号分隔的列表,它是以下关键字:行、vars和源。
如果没有指定调试级别,默认情况下,没有任何东西会附加到-g。
如果没有打开调试,这个属性将被忽略。
用户属性:maven.compiler.debuglevel。
将布尔设置为true,将调试信息包含在已编译的类文件中。
默认值是:true。
用户属性是:maven.编译。调试。
在-g命令行开关中附加的调试级字符串关键字列表。
法律值不是一个或一个逗号分隔的列表,它是以下关键字:行、vars和源。
如果没有指定调试级别,默认情况下,没有任何东西会附加到-g。
如果没有打开调试,这个属性将被忽略。
用户属性:maven.compiler.debuglevel。
- (3)参考链接
- javac -g的解释的参考链接为:http://www.linuxidc.com/Linux/2010-05/26395.htm
- maven编译插件配置参数列表的链接为:http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html
三、总结
记一次SpringMVC碰到的坑的更多相关文章
- 那些在BAE上部署node.js碰到的坑
在BAE上使用node.js半年多了,其中碰到了不少因为BAE云环境限制碰到的坑 写下来大家碰到了,也不用那么麻烦的去看好几天代码了,直接对症下药 官方公布的坑有: BAE是使用package.jso ...
- spring boot -- 无法读取html文件,碰到的坑
碰到的坑,无法Controller读取html文件 1. Controller类一定要使用@Controller注解,不要用@RestController 2. resource目录下创建templa ...
- 运行Appium碰到的坑们
运行Appium的时候,碰到的那些坑 1. java命令会出现error:could not open ...jvm.cfg 出现这种情况大多是因为电脑上之前安装过JDK,卸载重装之后,运行java命 ...
- 关于使用nodejs的mysql查询时碰到的坑
今天在编写登录模块时,碰到一个隐蔽的坑,故记录一番 在使用Node.js的mysql模块的query方法时,查询语句使用了 `select password from login where name ...
- Angular新手容易碰到的坑
在Angular群里回答新手问题一段时间了,有一些Angular方面的坑留在这里备查,希望能对各位有所帮助.这个文章将来会随时更新,不会单独开新章,欢迎各位订阅. Q1.<div ng-incl ...
- 记C函数指针的“小坑”
今天遇到一个C函数指针的小坑,索性记下来. 我在a.c 文件里面,引用b.c 文件的函数声明作为指针引用 比如在a.c生命一个函数指针 typedef void (*free)(void *val) ...
- 微信小程序里碰到的坑和小知识
本文作者:dongtao 来自:授权地址 本人低级程序员,以下bug不能确保在其它地方可以以相同的原因复现.同时, 出现很多bug的原因是小程序的基本知识还有编码的基本功不到位造成 路还很长,共勉 ...
- 记C语言浮点数运算处理 "坑" 一则
看一小段C语言程序: int main() { float x = 1.3; x = x - (int)x; ); ; } 在你心目中, 变量 I 是怎样的结果? 如果你理所当然地认为是3的话, 那么 ...
- 记一个JAVA关于日期的坑
JAVA解析日期格式代码,之前一直写成:“yyyy-MM-dd hh:mm”,比如"2016-01-18 11:00"."2016-01-18 15:00"都可 ...
随机推荐
- VS2010部署相关
找到一篇写得最负责的.贴住收藏了: http://blog.csdn.net/xhf55555/article/details/7702212. 之前在其它地方找的都缺胳膊少腿,真不知他们自己怎么实现 ...
- FragmentStatePagerAdapter和FragmentPagerAdapter区别
FragmentPageAdapter和FragmentStatePagerAdapter 我们简要的来分析下这两个Adapter的区别: FragmentPageAdapter:和PagerAdap ...
- Expo大作战(十六)--expo结合firebase 一个nosql数据库(本章令我惊讶但又失望!)
简要:本系列文章讲会对expo进行全面的介绍,本人从2017年6月份接触expo以来,对expo的研究断断续续,一路走来将近10个月,废话不多说,接下来你看到内容,讲全部来与官网 我猜去全部机翻+个人 ...
- 有关于《Linux C编程一站式学习》(备份)
Linux C编程一站式学习 -- PDF版本,共37章: Linux C编程一站式学习 -- 在线版,来自灰狐: Linux C编程一站式学习 -- 在线版,来自亚嵌教育: Linux C一站式学习 ...
- c#中partial 作用
申明一下:我也是在百度上找的答案,然后合起来的,这样感觉好理解一点!partial是局部类型的意思就是说有这个关键字的类.结构或接口可以写成几个部分比如: public partial class P ...
- 解决JBoss只能通过localhost访问不能通过IP的问题
前序 现在EJB是真的有点落伍了么,网上找点资料都挺难的样子,而且都是很久的了..好吧,最近对EJB有点兴趣学习一下,结果下载到服务器启动后,居然不能直接通过服务器IP访问,也是醉了,默认只能通过本地 ...
- C#-老生常谈的 值类型与引用类型
特殊的String 说起值类型和引用类型,大家都知道这么个事,很多时候我们会拿String做值类型来做比较,但实际上String虽然是值类型,却表现的有点特别 String示例 看下面的一个例子: 话 ...
- JVM学习笔记-JVM模型
JVM学习笔记 == 标签(空格分隔): jvm 学习笔记全部来自于<深入理解java虚拟机>总结 jvm内存示意图 虚拟机栈(Java Virtual Machine Stacks): ...
- 50家硅谷IT公司技术博客
分享一下 50 家硅谷优秀 IT 公司技术博客,从中可以了解企业文化,技术特色和设计语言,如果直接列出来很单调,加上点评,算吐槽版吧. 知名大厂 1. Facebook https://www.f ...
- 直播内容不合规怎么办?智能AI为您解决审核难题
背景 近些年来,视频直播快速发展,大量的直播平台如雨后春笋一般出现,但是这同样给直播内容的监管带来了巨大的挑战,一方面国家对于直播内容监管的要求日益严格,另一方面相对于文字内容的审核,多媒体内容的审核 ...