三种写法,test(String name), 
test(@RequestParam String name), 
test(@RequestParam("userName") String name), 
第一种如果没有name 参数不会报错, 
第二种没有name 参数会报错,(也可以设置required = false), 
第三种跟第二种的区别是name 参数换为userName。

为什么不写 @RequestParam 也能拿到参数?的更多相关文章

  1. Controller里写自己需要的Action,参数的名字必须和路由设置的参数名一致

    Controller里写自己需要的Action,参数的名字必须和路由设置的参数名一致,如果参数不一致,传过去为null

  2. vue中axios发送post请求,后端(@RequestParam)接不到参数

    遇到的问题描述 :axios post 请求,后端接收不到参数. 我们的接口是java,用@RequestParam来接收前端的参数 解决方案:使用qs:axios中已经包含有qs,所以无需重新安装, ...

  3. String MVC @RequestParam(required=false) int XXX 参数为空报错解决方法

    今天在用@RequestParam(required=false) int XXX 取参数的时候,当参数没有的时候Spring默认赋值为空.而此时使用基本类型int,所以报错,建议使用包装类 Inte ...

  4. js里写网页结构, 传函数参数

    如题 "<td align='center' height='30px' width='80px'><a href='javascript:sort(\"&quo ...

  5. 串行写队列的MYSQL大文本参数

    public void AsyncWriteDataBase() { var spName = ""; while (true) { try { var jsonText = Re ...

  6. turn.js中文API 写一个翻页效果的参数详细解释

    $('.flipbook').turn({     width: 922,     height: 600,     elevation: 50,     gradients: true,     a ...

  7. 这里有一个url=https://www/.baidu.com/s?id=111&name=yourname,写一个函数获取query的参数和值存放在一个对象

    console.log(getJson(url)); function getJson(url){ var obj={}; var arr=url.split("?")[1].sp ...

  8. RequestParam\@ResponseBody

    为什么不写 RequestParam 也能拿到参数 三种写法,test(String name), test(@RequestParam String name), test(@RequestPara ...

  9. Restful中 @RequestParam,@PathParam,@PathVariable等注解区别

    @RequestParam 和 @PathVariable 注解是用于从request中接收请求的,两个都可以接收参数,关键点不同的是@RequestParam 是从request里面拿取值,而 @P ...

随机推荐

  1. CodeForces 388A Fox and Box Accumulation (模拟)

    A. Fox and Box Accumulation time limit per test:1 second memory limit per test:256 megabytes Fox Cie ...

  2. [PWA] Show an Error when a POST or DELETE Fails in an Offline PWA

    We're storing JSON data in the cache - but that only applies to HTTP GET requests - and not to POST  ...

  3. Angular 学习笔记——$interpolate

    <!DOCTYPE HTML> <html ng-app="myApp"> <head> <meta http-equiv="C ...

  4. 显式启动Activity和隐式启动Activity

    1.显式启动Intent intent = new Intent(this, class);startActivity(intent); 2.隐式启动AndroidManifest.xml中定义某个A ...

  5. sone1动态树

    这尼吗桑心病狂的动态树:http://www.lydsy.com/JudgeOnline/problem.php?id=3153 终于让哥以一种碉堡的姿势过了: 牛B轰轰的最后两个都是我的...无法超 ...

  6. 【BIEE】02_新建资料库并创建简单分析

    一.新建资料库 1.开始→打开BI管理→点击新建资料库 2.文件→新建资料档案库 下一步 在下面的框中一次填入 连接类型:OCI 10g/11g(直接选择即可) 数据库名称:(DESCRIPTION ...

  7. 【DB2】根据映射表映射出结果

    第一步:创建语法 CREATE TABLE OLIVER_MAP(ID INT,COM_TYPE VARCHAR(100),COM_NAME VARCHAR(100),SR_UP DECIMAL(18 ...

  8. smali 语法参考

    原文见:http://www.blogjava.net/midea0978/archive/2012/01/04/367847.html Dalvik opcodes Author: Gabor Pa ...

  9. SpringSecurity学习一----------最简单的权限控制系统

    © 版权声明:本文为博主原创文章,转载请注明出处 1.项目结构 2.pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0& ...

  10. Element type &quot;Resource&quot; must be followed by either attribute specifications, &quot;&gt;&quot; or &quot;/&gt;&quot;.

    在xml中配置没有问题的情况下.检查是否有单词中间缺少 空格 .2个单词靠的太近的情况! 试了一下情况解决!