记一次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"都可 ...
随机推荐
- Oracle 远程链接oracle数据库服务器的配置
远程链接oracle数据库服务器的配置 by:授客 QQ:1033553122 原理: 一.Oracle客户端与服务器端的通讯机制 1.OracleNet协议 如下图所示,Oracle通过Oracle ...
- Express使用Https服务器
var fs = require('fs'); var http = require('http'); var https = require('https'); var privateKey = f ...
- 大数据【八】Flume部署
如果说大数据中分布式收集日志用的是什么,你完全可以回答Flume!(面试小心问到哦) 首先说一个复制本服务器文件到目标服务器上,需要目标服务器的ip和密码: 命令: scp filename i ...
- matlab练习程序(单层感知器)
clear all; close all; clc; %生成两组已标记数据 randn(); mu1=[ ]; S1=[ ; ; 0.4]; P1=mvnrnd(mu1,S1,); mu2=[ ]; ...
- selenium 校验文件下载成功
转自: http://www.seleniumeasy.com/selenium-tutorials/verify-file-after-downloading-using-webdriver-jav ...
- jquery插件导出excel和pdf(解决中文乱码问题)
参考文件:http://jackyrong.iteye.com/blog/2169683 https://my.oschina.net/aruan/blog/418980 https://segmen ...
- MySQL索引原理及慢查询优化-zz
https://tech.meituan.com/mysql-index.html MySQL凭借着出色的性能.低廉的成本.丰富的资源,已经成为绝大多数互联网公司的首选关系型数据库.虽然性能出色,但所 ...
- CSS未知宽高元素水平垂直居中
方法一 :table.cell-table 思路:显示设置父元素为:table,子元素为:cell-table,这样就可以使用vertical-align: center,实现水平居中优点:父元素(p ...
- git命令:全局设置用户名邮箱配置
1.查看git配置信息 git config --list 2.查看git用户名 git config user.name 3.查看邮箱配置 git config user.email 4.全局配置用 ...
- rename 批量修改文件名简单用法
有的时候我们需要批量创建文件做测试,为了做区分,一般只要稍稍动动文件名即可,MV命令既可以移动文件,也是可以修改文件名的,但批量修改文件名MV做不到,此时,我们可以用rename命令批量修改是蛮不错的 ...