记一次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"都可 ...
随机推荐
- jquery 绑定事件 获取方式 --------------data event 获取
//绑定事件 bind event $("body").on("click",function(){ console.log("in") } ...
- qt多线程信号槽传输方式
//简单介绍一下QT信号与槽的连接方式: //Qt::AutoConnection表示系统自动选择相应的连接方式,如果信号与槽在同一线程,就采用Qt::DirectConnection, //如 ...
- java io详解(1)
一.java io结构图 二.java io的开始:文件 三.字节流: 一.java io结构图 流分类: 1.Java的字节流 InputStream是所有字节输入流的祖先,而OutputSt ...
- 简单实现MySQL数据库的日志审计
时间 2018-12-23 08:01:11 FreeBuf 原文 https://www.freebuf.com/articles/es/192062.html 主题 MySQL 0×0 背景 ...
- 《MySQL技术内幕:InnoDB存储引擎(第2版)》书摘
MySQL技术内幕:InnoDB存储引擎(第2版) 姜承尧 第1章 MySQL体系结构和存储引擎 >> 在上述例子中使用了mysqld_safe命令来启动数据库,当然启动MySQL实例的方 ...
- 【概率论】条件概率 & 全概率公式 & 朴素贝叶斯公式
0. 说明 条件概率 & 全概率公式 & 朴素贝叶斯公式 学习笔记 参考 scikit-learn机器学习(五)--条件概率,全概率和贝叶斯定理及python实现 1. 条件概率 [定 ...
- [Spark RDD_add_1] groupByKey & reduceBykey 的区别
[groupByKey & reduceBykey 的区别] 在都能实现相同功能的情况下优先使用 reduceBykey Combine 是为了减少网络负载 1. groupByKey 是没有 ...
- windows下,怎么轻易拷贝一个文件的完整路径?
1. 到目录下,复制文件 2. win+R ,打开"运行"输入框 3.ctrl+v
- Hexo搭建博客笔记
Hexo搭建(建议看ppt:https://files.cnblogs.com/files/-SANG/%E4%BD%A0%E7%9A%84%E7%8C%AB.pptx ) 安装Git https:/ ...
- C# 生成随机订单号
//生成固定位数的随机数 //ran.Next(999)生成的是1-999的随机数,不能保证位数是固定的. public static string GenerateOrderNo() ...