当前位置:网站首页>The role of @requestmapping in the project and how to use it
The role of @requestmapping in the project and how to use it
2022-07-26 19:15:00 【Work hard, work hard, gzc】
One 、 effect
In our Spring In the project , adopt @Controller After the annotation finds the corresponding control class , You also need to know how each specific request is handled inside the controller , And that's where it comes in org.springframework.web.bind.annotation.RequestMapping Note the . RequestMapping Annotation types are used to map a request or a method , Its annotation form is @RequestMapping , You can use this annotation to mark in a request , That is, our specific method .
Two 、 Use
[email protected] Mark on class
When labeled on a class , All methods in the class will be mapped to requests relative to the class level , Indicates that all requests processed by the controller are mapped to value The path specified by the property value .

In the diagram above , Add our @RequestMapping After the note , Our login request url namely (/user/login)、 Registration request url namely (/user/register)
[email protected] Mark on the method
When annotated on a method , This method will become a request processing method , It will receive the corresponding... In the program URL When called .
[email protected] Properties of annotations 
Be careful : All properties are optional , But its default attribute is value . When value Is its unique property , Property names can be omitted , For example, the following two labels have the same meaning :
@RequestMapping(value = “/login”)
@RequestMapping(“/login”)
边栏推荐
- In this competition, you who can understand the topic have great potential
- OpenSSF 基金会总经理 Brian Behlendorf :预计 2026 年将有 4.2 亿个开源
- Operations research 69 | explanation of classic examples of dynamic planning
- Usage scenarios for automated testing
- EN 1504-7混凝土结构保护和修理用产品钢筋防腐—CE认证
- MapReduce (II)
- Synchronized理论
- Introduction to Seata
- 配置服务器环境
- Database expansion can also be so smooth, MySQL 100 billion level data production environment expansion practice
猜你喜欢

(ICLR-2022)TADA!用于视频理解的时间自适应卷积

2022 welder (elementary) operation certificate examination question bank and simulation examination

VTK (the Visualization Toolkit) loads STL models

支持代理直连Oracle数据库,JumpServer堡垒机v2.24.0发布

JS question brushing plan - array

ReentrantLock学习之---基础方法

Tensor Rt的int8量化原理

PMP practice once a day | don't get lost in the exam -7.26 (including agility + multiple choices)

【MySQL从入门到精通】【高级篇】(八)聚簇索引&非聚簇索引&联合索引

MapReduce (II)
随机推荐
【考研词汇训练营】Day 13 —— reliance,expert,subject,unconscious,photograph,exaggeration,counteract
2022年流动式起重机司机考试试题模拟考试平台操作
时空预测5-GAT
【MySQL从入门到精通】【高级篇】(八)聚簇索引&非聚簇索引&联合索引
Zbxtable 2.0 heavy release! 6 major optimization functions!
手写一个Starter
OpenSSF 基金会总经理 Brian Behlendorf :预计 2026 年将有 4.2 亿个开源
Unity farm 2 - planting system
Verification palindrome string II of leetcode simple question
Advanced template (runner's notes)
ZbxTable 2.0 重磅发布!6大主要优化功能!
JS刷题计划——链表
MySQL - function and constraint commands
配置服务器环境
Article 7:exited on desktop-dff5kik with error code -1073741511
LeetCode简单题之数组能形成多少数对
PMP每日一练 | 考试不迷路-7.26(包含敏捷+多选)
Unity 农场 2 —— 种植系统
TypeScript阶段学习
Distributed transaction Seata