当前位置:网站首页>@Requestparam use
@Requestparam use
2022-07-28 17:31:00 【Uh huh, uh huh】
1、 The difference between adding and not adding
@RequestMapping("/list1")
public String test1(int userId) {
return "list";
}
@RequestMapping("/list2")
public String test2(@RequestParam int userId) {
return "list";
}
(1) No addition @RequestParam The parameter name of the front end must be consistent with the variable name of the back-end controller to take effect
(2) No addition @RequestParam Parameters are not required , Add @RequestParam The writing parameter is required . but @RequestParam Can pass @RequestParam(required = false) Set to not required .
(3)@RequestParam Can pass @RequestParam(“userId”) perhaps @RequestParam(value = “userId”) Specify the passed in parameter name .
(4)@RequestParam Can pass @RequestParam(defaultValue = “0”) Specify parameter defaults
(5) If the interface has a back-end besides the front-end call RPC call , Cannot be omitted @RequestParam, otherwise RPC The parameter will not be found and an error will be reported
(6) During the interview :
- No addition @RequestParam annotation :url With or without parameters , Input localhost:8080/list1 as well as localhost:8080/list1userId=xxx Methods can execute
- Add @RequestParam annotation :url Must have parameters . That is, you enter directly localhost:8080/list2 Will report a mistake , Method... Will not be executed . Input only localhost:8080/list2userId=xxx To execute the corresponding method
边栏推荐
- MySQL detailed learning tutorial (recommended Collection)
- 【kibana】问题整理 kibana 7.x No indices match pattern “apm-*“
- Goweb开发之Beego框架实战:第二节 项目初始化配置
- Jupyter notebook win installation record
- C语言实现扫雷小游戏
- 2022 Niuke multi school second CDE
- Linear algebra and matrix theory (VIII)
- LNMP源码编译安装
- Steps to configure V530 switch
- Batch download files
猜你喜欢

With a total data volume of more than trillions of lines, Yuxi cigarette factory can easily deal with it by correctly selecting the timing database

【atlas】atlas 编译报错整理(全)

The practice of the beego framework for goweb development: Section V project construction and user registration

Selection and application of capacitor in high speed circuit -- detailed explanation

Visual Studio 2012/2015发布Web应用连同.cs源码一起发布

WPF command button transparent style

Message Passing for Complex Question Answering over Knowledge Graphs

Goweb开发之Beego框架实战:第三节 程序执行流程分析

Basic principle of asynchronous FIFO (simple implementation based on Verilog)

【CDH】通过 ClouderaManager 配置CDH组件用 prometheus 监控采集JMX信息
随机推荐
Self study examination in April 2021
Mysql database addition, deletion, modification and query (detailed explanation of basic operation commands)
Verilog daily question (vl28 plus and minus counter)
Verilog 每日一题(VL26 简易秒表)
Visual Studio 2012/2015发布Web应用连同.cs源码一起发布
Verilog 每日一题 (VL27 可置位计数器)
The practice of the beego framework for goweb development: Section V project construction and user registration
Verilog 每日一题 (VL30 RAM的简单实现)
面试官:算法刷题实录.pdf我居然答不上来
What does the service grid that has been popular for two years bring to microservices? (Reprinted)
MySQL详细学习教程(建议收藏)
LNMP源码编译安装
【atlas】atlas 编译报错整理(全)
Difference between reconnaissance aircraft and early warning aircraft
线性代数及矩阵论(九)
C#遍历集合
The practice of beego framework developed by goweb: Section 4 database configuration and connection
Asynchronous circuit design -- principle and example of synchronous pulser
Verilog 每日一题 (VL24 多bit MUX同步器 跨时域输出)
AMQP协议详解