记一次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"都可 ...
随机推荐
- JSP基本语法总结【1】(jsp工作原理,脚本元素,指令元素,动作元素)
时隔半年,回头对jsp复习整理一下,温故而知新. jsp工作原理: jsp服务器管理jsp页面分两个阶段:转换阶段(translation phase)和执行阶段(execution phase). ...
- linux chmod 给目录或文件赋权限 可读可写可执行
前提: mode权限设定字串,格式:[ugoa...][[+-=][rwxX]...][,...] 其中u表示拥有者(user),g表示与拥有者属于同一个群体(group),o表示其他以外的人(ot ...
- 看jQuery的这几天
现在在做SPA时,有很多非常好用而且流行的前端框架,比如Vue,React,Angular等,jQuery似乎要逐渐退出前端的舞台了.不得不说,'write less,do more' 这句话吸引了我 ...
- Oracle EBS INV 创建货位
create or replace PROCEDURE XX_CREATE_LOCATOR AS -- Common Declarations l_api_version NUMBER := 1.0; ...
- mysql workbench中my.ini路径不一样
mysql workbench中的my.ini路径与mysql服务中的路径不一样 删除mysql workbench的配置文件即可解决 win7下的配置文件路径: %APPDATA\MySQL\Wor ...
- FZU Monthly-201901 获奖名单
FZU Monthly-201901 获奖名单 冠军: S031702338 郑学贵 一等奖: S031702524 罗继鸿 S031702647 黄海东 二等奖: S031702413 韩洪威 S0 ...
- 团队作业——Beta冲刺1
团队作业--Beta冲刺 冲刺任务安排 杨光海天 今日任务:开会讨论下,Beta阶段主要的冲刺内容 明日任务:根据冲刺内容,具体分配个人任务,对于冲刺内容做准备 吴松青 今日任务:跟新组员熟悉下,联络 ...
- SSL/TLS Diffie-Hellman Modulus <= 1024 位 (LogJam) 使用2048位或更高的Diffie-Hellman
1.http://slproweb.com/products/Win32OpenSSL.html 下载 SSL 并安装 2.设置环境变量,例如工具安装在C:\OpenSSL-Win64,则将C:\O ...
- PyQt5--Position
# -*- coding:utf-8 -*- ''' Created on Sep 13, 2018 @author: SaShuangYiBing ''' import sys from PyQt5 ...
- 在react中使用intro.js的的一些经验
react逐渐热了起来,但是新的东西毕竟前辈的经验少一些,前段时间自己在react中用到intro.js时,得到的资料甚少,摸索后便将一些心得记录下来了~ 1 intro.js的引入,这一点请看上一篇 ...