@RequestParam注解的基本用法

@RequestParam注解的基本用法在处理方法入参处使用 RequestParam 可以把请求参数传递给请求方法 value 值即请求参数的参数名 required 该参数是否必须 默认为 true d

在处理方法入参处使用@RequestParam可以把请求参数传递给请求方法。

  • value值即请求参数的参数名;
  • required该参数是否必须。默认为true;
  • defaultValue请求参数的默认值。
 
 
  1. @RequestMapping(value = "/testRequestParam")
  2. public String testRequestParam(@RequestParam(value = "username") String username,
  3. @RequestParam(value = "age", required = false, defaultValue = "0") int age) {
  4. System.out.println( "testRequestParam, username: " + username + " , age: " + age);
  5. return SUCCESS;
  6. }

<a href=”testRequestParam?username=atguigu&age=11″>testRequestParam</a>

  •  <li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true"> <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#csdnc-thumbsup"></use> </svg><span class="name">点赞</span> <span class="count"></span> </a></li> <li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{&quot;mod&quot;:&quot;popu_824&quot;}"><svg class="icon" aria-hidden="true"> <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-csdnc-Collection-G"></use> </svg><span class="name">收藏</span></a></li> <li class="tool-item tool-active is-share"><a href="javascript:;"><svg class="icon" aria-hidden="true"> <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-csdnc-fenxiang"></use> </svg>分享</a></li> <!--打赏开始--> <!--打赏结束--> <li class="tool-item tool-more"> <a> <svg t="52" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg> </a> <ul class="more-box"> <li class="item"><a class="article-report">文章举报</a></li> </ul> </li> </ul> </div> </div> <div class="person-messagebox"> <div class="left-message"><a href="https://blog.csdn.net/_"> <img src="https://profile.csdnimg.cn/B/4/7/3__" class="avatar_pic" username="_"> <img src="https://g.csdnimg.cn/static/user-reg-year/1x/2.png" class="user-years"> </a></div> <div class="middle-message"> <div class="title"><span class="tit"><a href="https://blog.csdn.net/_" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}" target="_blank">Tong XU</a></span> </div> <div class="text"><span>发布了422 篇原创文章</span> · <span>获赞 27</span> · <span>访问量 10万+</span></div> </div> <div class="right-message"> <a href="https://bbs.csdn.net/topics/" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-messageboard">他的留言板 </a> <a class="btn btn-sm bt-button personal-watch" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}">关注</a> </div> </div> </div> 
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/233199.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 一文搞懂MySQL索引(清晰明了)[通俗易懂]

    一文搞懂MySQL索引(清晰明了)[通俗易懂]索引是对数据库表中一列或多列的值进行排序的一种结构。MySQL索引的建立对于MySQL的高效运行是很重要的,索引可以大大提高MySQL的检索速度。MySQL中常用的索引结构(索引底层的数据结构)有:B-TREE,B+TREE,HASH等。MySQL的索引有两种分类方式:逻辑分类和物理分类。对于InnoDB和MyISAM而言,主键索引是根据主关键字来构建的B+树存储结构,辅助索引则是根据辅助键来构造的B+树存储结构,彼此的索引树都是相互独立的。

    2022年6月24日
    27
  • js原生实现FastClick事件

    js原生实现FastClick事件js原生实现FastClick事件注明:本人学习javascript时间不长,最近一直在做web端的手机网页和微信应用,由于最近有用到类似fastclick的功能,在原来的程序中用touchstart和touchend事件模拟,现在尝试将其封装,得到了以下两种有问题的方案。分享给大家,另求大神指导

    2022年6月19日
    26
  • USB协议分析仪

    USB协议分析仪USB协议分析仪

    2022年6月22日
    82
  • 过压保护(2)_过压保护值和欠压保护值

    过压保护(2)_过压保护值和欠压保护值http://www.elecfans.com/dianlutu/protect/2009102499242.html采用CW136构成的过压保护电路图中是采用CW136构成的过压保护电路,当电子设备

    2022年8月2日
    8
  • pycharm菜单栏不见了_pycharm左侧项目栏隐藏

    pycharm菜单栏不见了_pycharm左侧项目栏隐藏ctrl+Alt+shif打开搜索窗口,然后输入Experimentalfeatures 取消linux.native.menu选项的复对勾,应用更改并关闭,重启PyCharm。

    2022年8月25日
    6
  • 物业 小程序_智慧物业平台app安卓版

    物业 小程序_智慧物业平台app安卓版智慧小区小程序功能小区资讯展示小区最新的资讯和动态.让小区居民对小区的活动有全盘的了解.小区资讯详情.将对活动的具体情况.有一个更详尽的描述。物业通知由物业服务公司通过管理后台发布.能将最新的物业通知推送到用户手机桌面.实现物业管理信息的即时推送.点击即可查看详情。邮包提醒将以数字的方式,提醒住户有多少邮包在传达室尚未领取,领取完成后,该数字将自动归零。小区服务整合小区所有服务项目,如物业维修、超…

    2022年10月10日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号