当前位置:网站首页>@The difference between requestparam and @pathvariable annotations
@The difference between requestparam and @pathvariable annotations
2022-07-26 00:21:00 【qq_ twenty-five million seventy-three thousand two hundred and 】
from :
@RequestParam,@PathVariable The difference between the two notes
The following is about @RequestParam,@PathVariable Differences between the three annotations , As shown below :
@RequestParam @PathVariable The function of annotation : For from request To receive the request , Both can receive parameters @RequestParam @PathVariable The difference between annotations : @RequestParam It's from request Take it inside @PathVariable Is from a URI Fill in the template example :
@RequestParam Sample sharing
http://localhost:8080/springmvc/test/888?param1=999¶m2=666
Use the above URL Get parameter information , As shown below :
public String getInfo(
@RequestParam(value="param1", required=true) String param1,
@RequestParam(value="param2", required=false) String param2){
//
}
@RequestParam The following four parameters are supported
defaultValue: If the request does not carry this parameter , Or the parameter is empty , Then the default value is enabled
name: Bind the name of this parameter , Want to follow URL It's the same as above
required: Is this parameter required
value: Follow name The same thing , yes name An alias for property
example :
@PathVariable
http://localhost:8080/springmvc/test/888?param1=999¶m2=666
@RequestMapping("/test/{id}")
public String getInfo(@PathVariable(value="id") String id,
@RequestParam(value="param1", required=true) String param1,
@RequestParam(value="param2", required=false) String param2){
//id The value of is 888
}边栏推荐
- MPLS experiment
- 链表相关方法
- 关于“DBDnet: A Deep Boosting Strategy for ImageDenoising“一文理解
- Js理解之路:Js常见的6中继承方式
- Multitask programming
- Old laptop becomes server (laptop + intranet penetration)
- Detailed explanation of C language preprocessing
- Unity—欧拉角,四元数
- "Demons dance", is the bull market over? 2021-05-13
- FreeRTOS personal notes - mutex
猜你喜欢

Unity -- Euler angle, quaternion

J9 number theory: what is Dao mode? Obstacles to the development of Dao

Matlab makes the image of serial port output data in real time

The bull market is not over yet, and there is still 2021-05-18 in the second half

MySQL——数据库日志

Representation and implementation of stack (C language)

Redis夺命十二问,你能扛到第几问?

Nest. JS uses express but not completely

What does it mean that the web server stops responding?

Opencv learning Day6
随机推荐
VMware ESXI7.0版本的安装与配置
Understanding of "dbdnet: a deep boosting strategy for imagedenoising"
NVIDIA programmable reasoning accelerator tensorrt learning notes (III) -- Accelerating reasoning
为了拿捏 Redis 数据结构,我画了 40 张图(完整版)
The bull market is not over yet, and there is still 2021-05-18 in the second half
C语言 预处理详解
滑动窗口_
Instructions for pinduoduo's API to get the list of goods according to keywords
LeetCode_ 55_ Jumping game
SSM environment integration
Sorting out the encapsulation classes of control elements in appium
[brother hero July training] day 24: linear tree
letfaw
测试7年,面试华为最后面议要薪1万,HR说我不尊重华为,他们没有那么低薪资的岗位~
How does the server build a virtual host?
Multitask programming
多任务编程
京东获取推荐商品列表 API
Representation and implementation of stack (C language)
Thymeleaf view integration