In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about how to use @ RequestMapping annotations in Spring MVC. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something from this article.
The @ RequestMapping annotation and RequestMappingHandlerMapping work together, so first figure out the attributes in @ RequestMapping. The @ RequestMapping annotated class function will be packaged and stored as a RequestMappingInfo object, and when a http request is received, it will find a best match according to request.
Name
The name attribute is a name for the RequestMapping, but I haven't found out what it does.
Value 、 path
The request path for http, which can be either a regular expression or a parameter placeholder. If this property is written at the class level, then other methods annotated by @ RequestMapping in the class class will be useful.
Method
Http request method, GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE. If this property is written at the class level, then other methods annotated by @ RequestMapping in the class class will be useful.
Params
The qualification of the parameter, the way the expression is expressed. MyParamroomroommyValue indicates that there must be a parameter with the name "myParam" and a value not equal to "myValue". Or myParam=myValue, myParam means that there must be a parameter named "myParam", and the parameter value can be arbitrary. ! myParam indicates that it must not contain the parameter "myParam".
If this property is written at the class level, then other methods annotated by @ RequestMapping in the class class will be useful.
Headers
This headers is used in the same way as params. It represents the request header of the http. If this property is written at the class level, then other methods annotated by @ RequestMapping in the class class will be useful.
Consumes
Represents the "Content-Type" request header in the http request header. Such as text/plain "," application/*. If this property is written at the class level, then other methods annotated by @ RequestMapping in the class class will be useful.
Produces
Represents the Accept request header in the http request header, assuming your Accept=application/json, then the request will be more accurately mapped to the produces=application/json method. If this property is written at the class level, then other methods annotated by @ RequestMapping in the class class will be useful.
After reading the above, do you have any further understanding of how to use the @ RequestMapping annotation in Spring MVC? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.