当前位置:网站首页>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”)
边栏推荐
猜你喜欢

手写一个Starter

MapReduce (II)

MySQL学习笔记-2.如何提高sql语句的查询性能

LeetCode简单题之数组能形成多少数对

SD NAND与eMMC优劣势对比

Reentrantlock learning - lock release process

This article explains in detail the five benefits that MES system brings to enterprises, with application scenarios

SMMU carding

I'm cool, so I'm here

Gongfu developer community is settled! On July 30!
随机推荐
TypeScript阶段学习
J2 Redis之 AOF&RDB
【考研词汇训练营】Day 14 —— panini,predict,access,apologize,sense,transport,aggregation
I'm cool, so I'm here
2022 tea master (intermediate) examination question simulation examination question bank and answers
ZbxTable 2.0 重磅发布!6大主要优化功能!
VTK (the Visualization Toolkit) loads STL models
.net CLR GC dynamic loading transient heap threshold calculation and threshold excess calculation
How to become an excellent test / development programmer? Focus on planning and then move
Write a starter
Synchronized theory
[interview question] 1384- share 44 JS problems. Half right is a master
rancher部署kubernetes集群
议程速递 | 7月27日分论坛议程一览
JS question brushing plan - array
Redis learning notes-2. Use of the client
MySQL learning notes -2. how to improve the query performance of SQL statements
Brand new! Uncover the promotion route of Ali P5 Engineer ~p8 architect
Sentinel isolation and degradation
VPC nat (Sant, nant) experiment