记一次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"都可 ...
随机推荐
- android开发之braodCast
广播问题: 遇到了broadcast中sendBroadcast之后,注册registerReceiver的receiver接受不到广播,原因是permisson权限问题. 自定义的permissio ...
- 抽象数据类型(ADT)
概念 抽象数据类型(ADT),脱离具体实现定义数据结构,它的定义着重于做什么,而忽略怎么做 举例 列表.栈.队列 列表 列表,也叫线性表 抽象定义:数据项线性排列,可以插入某一项,删除某一项,读取某一 ...
- ASP.NET Core Razor生成Html静态文件
一.前言 最近做项目的时候,使用Util进行开发,使用Razor写前端页面.初次使用感觉还是不大习惯,之前都是前后端分离的方式开发的,但是使用Util封装后的Angular后,感觉开发效率还是杠杠滴. ...
- python终端总是无法删除字符
yum install readline-devel
- c#创建文件( File.Create() )后对文件写操作出错的分析
在C#中,使用system.IO.File.Create()创建完一个文件之后,如果需要对这个文件进行写操作,会出现错误,提示你“这个文件正在被使用”. 原因是System.IO.File.Creat ...
- 简单实现MySQL数据库的日志审计
时间 2018-12-23 08:01:11 FreeBuf 原文 https://www.freebuf.com/articles/es/192062.html 主题 MySQL 0×0 背景 ...
- http的断点续传
要实现断点续传的功能,通常都需要客户端记录下当前的下载进度,并在需要续传的时候通知服务端本次需要下载的内容片段. HTTP1.1协议(RFC2616)中定义了断点续传相关的HTTP头 Range和Co ...
- 【转】Java学习---内存溢出的排查经历
[原文]https://www.toutiao.com/i6595365358301872643/ 前言 OutOfMemoryError 问题相信很多朋友都遇到过,相对于常见的业务异常(数组越界.空 ...
- DevExpress11、TreeList
一.简介 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; ...
- Java实现XML和JavaBean互转 - XStream
1.简介 XStream是一个序列化JavaBean为XML文件以及反序列化的工具. 2.准备 2.1.XML回顾 在学习这部分内容前,假设你对XML以及有一定的了解,至少能够分辨出XML的元素.属性 ...