当前位置:网站首页>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”)
边栏推荐
- Arrangement of information security emergency plan
- 实用工具网站推荐
- 工赋开发者社区 | 定了!就在7月30日!
- Typescript stage learning
- CoVOS:无需解码!利用压缩视频比特流的运动矢量和残差进行半监督的VOS加速(CVPR 2022)...
- 【Swoole系列3.1】进程、线程、协程,面试你被问了吗?
- 模型定义#pytorch学习
- 【考研词汇训练营】Day 13 —— reliance,expert,subject,unconscious,photograph,exaggeration,counteract
- 模板进阶(跑路人笔记)
- Tensor RT's int8 quantization principle
猜你喜欢

How far can Volvo, which has lost its "safety brand" due to declining sales and marginalization of its brand?

(ICLR-2022)TADA! Time adaptive convolution for video understanding

ReentrantLock学习之---释放锁过程
![[swoole series 3.1] have you been asked about processes, threads, and collaborations during the interview?](/img/62/2aa1999f461ea5afd19b78bcd4ded8.jpg)
[swoole series 3.1] have you been asked about processes, threads, and collaborations during the interview?

JVM内存模型之Volatile关键字

MySQL - function and constraint commands

Brian behrendorf, general manager of openssf Foundation: it is estimated that there will be 420million open sources in 2026

Seata 入门简介

J3:Redis主从复制

LeetCode简单题之验证回文字符串 Ⅱ
随机推荐
In this competition, you who can understand the topic have great potential
CTO will teach you: how to take over his project when a technician suddenly leaves
rancher部署kubernetes集群
Leetcode notes: biweekly contest 83
MapReduce(二)
Briefly describe the 11 core functional modules of MES system
MongoDB stats统计集合占用空间大小
What aspects should be considered in the selection of MES system?
MES系统的选择需重点考虑哪些方面?
Basic module and example pytorch learning
The first letter of leetcode simple question appears twice
2022 Shanghai safety officer C certificate operation certificate examination question bank simulated examination platform operation
Sentinel 隔离与降级
J1:Redis为什么这么快+基本结构
rancher部署kubernetes集群
Brian behrendorf, general manager of openssf Foundation: it is estimated that there will be 420million open sources in 2026
JS使用readline来实现终端输入数据
【Swoole系列3.1】进程、线程、协程,面试你被问了吗?
Tensorflow-GPU 1.15安装
After the exam on June 25, see how the new exam outline reviews PMP