==================================================
"RequestMapping is an annotation used to process request address mapping, which can be used on classes or methods. Used on classes, it means that all methods in the class that respond to requests use this address as the parent path."
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Mapping
public @interface RequestMapping {
/**
* Assign a name to this mapping.
* <p><b>Supported at the type level as well as at the method level!</b>
* When used on both levels, a combined name is derived by concatenation
* with "#" as separator.
* @see org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder
* @see org.springframework.web.servlet.handler.HandlerMethodMappingNamingStrategy
*/
String name() default "";
/**
* The primary mapping expressed by this annotation.
* <p>In a Servlet environment this is an alias for {@link #path}.
* For example {@code @RequestMapping("/foo")} is equivalent to
* {@code @RequestMapping(path="/foo")}.
* <p>In a Portlet environment this is the mapped portlet modes
* (i.e. "EDIT", "VIEW", "HELP" or any custom modes).
* <p><b>Supported at the type level as well as at the method level!</b>
* When used at the type level, all method-level mappings inherit
* this primary mapping, narrowing it for a specific handler method.
*/
@AliasFor("path")
String[] value() default {};
/**
* In a Servlet environment only: the path mapping URIs (e.g. "/myPath.do").
* Ant-style path patterns are also supported (e.g. "/myPath/*.do").
* At the method level, relative paths (e.g. "edit.do") are supported
* within the primary mapping expressed at the type level.
* Path mapping URIs may contain placeholders (e.g. "/${connect}").
* <p><b>Supported at the type level as well as at the method level!</b>
* When used at the type level, all method-level mappings inherit
* this primary mapping, narrowing it for a specific handler method.
* @see org.springframework.web.bind.annotation.ValueConstants#DEFAULT_NONE
* @since 4.2
*/
@AliasFor("value")
String[] path() default {};
/**
* The HTTP request methods to map to, narrowing the primary mapping:
* GET, POST, HEAD, OPTIONS, PUT, PATCH, DELETE, TRACE.
* <p><b>Supported at the type level as well as at the method level!</b>
* When used at the type level, all method-level mappings inherit
* this HTTP method restriction (i.e. the type-level restriction
* gets checked before the handler method is even resolved).
* <p>Supported for Servlet environments as well as Portlet 2.0 environments.
*/
RequestMethod[] method() default {};
/**
* The parameters of the mapped request, narrowing the primary mapping.
* <p>Same format for any environment: a sequence of "myParam=myValue" style
* expressions, with a request only mapped if each such parameter is found
* to have the given value. Expressions can be negated by using the "!=" operator,
* as in "myParam!=myValue". "myParam" style expressions are also supported,
* with such parameters having to be present in the request (allowed to have
* any value). Finally, "!myParam" style expressions indicate that the
* specified parameter is <i>not</i> supposed to be present in the request.
* <p><b>Supported at the type level as well as at the method level!</b>
* When used at the type level, all method-level mappings inherit
* this parameter restriction (i.e. the type-level restriction
* gets checked before the handler method is even resolved).
* <p>In a Servlet environment, parameter mappings are considered as restrictions
* that are enforced at the type level. The primary path mapping (i.e. the
* specified URI value) still has to uniquely identify the target handler, with
* parameter mappings simply expressing preconditions for invoking the handler.
* <p>In a Portlet environment, parameters are taken into account as mapping
* differentiators, i.e. the primary portlet mode mapping plus the parameter
* conditions uniquely identify the target handler. Different handlers may be
* mapped onto the same portlet mode, as long as their parameter mappings differ.
*/
String[] params() default {};
/**
* The headers of the mapped request, narrowing the primary mapping.
* <p>Same format for any environment: a sequence of "My-Header=myValue" style
* expressions, with a request only mapped if each such header is found
* to have the given value. Expressions can be negated by using the "!=" operator,
* as in "My-Header!=myValue". "My-Header" style expressions are also supported,
* with such headers having to be present in the request (allowed to have
* any value). Finally, "!My-Header" style expressions indicate that the
* specified header is <i>not</i> supposed to be present in the request.
* <p>Also supports media type wildcards (*), for headers such as Accept
* and Content-Type. For instance,
* <pre class="code">
* @RequestMapping(value = "/something", headers = "content-type=text/*")
* </pre>
* will match requests with a Content-Type of "text/html", "text/plain", etc.
* <p><b>Supported at the type level as well as at the method level!</b>
* When used at the type level, all method-level mappings inherit
* this header restriction (i.e. the type-level restriction
* gets checked before the handler method is even resolved).
* <p>Maps against HttpServletRequest headers in a Servlet environment,
* and against PortletRequest properties in a Portlet 2.0 environment.
* @see org.springframework.http.MediaType
*/
String[] headers() default {};
/**
* The consumable media types of the mapped request, narrowing the primary mapping.
* <p>The format is a single media type or a sequence of media types,
* with a request only mapped if the {@code Content-Type} matches one of these media types.
* Examples:
* <pre class="code">
* consumes = "text/plain"
* consumes = {"text/plain", "application/*"}
* </pre>
* Expressions can be negated by using the "!" operator, as in "!text/plain", which matches
* all requests with a {@code Content-Type} other than "text/plain".
* <p><b>Supported at the type level as well as at the method level!</b>
* When used at the type level, all method-level mappings override
* this consumes restriction.
* @see org.springframework.http.MediaType
* @see javax.servlet.http.HttpServletRequest#getContentType()
*/
String[] consumes() default {};
/**
* The producible media types of the mapped request, narrowing the primary mapping.
* <p>The format is a single media type or a sequence of media types,
* with a request only mapped if the {@code Accept} matches one of these media types.
* Examples:
* <pre class="code">
* produces = "text/plain"
* produces = {"text/plain", "application/*"}
* produces = "application/json; charset=UTF-8"
* </pre>
* <p>It affects the actual content type written, for example to produce a JSON response
* with UTF-8 encoding, {@code "application/json; charset=UTF-8"} should be used.
* <p>Expressions can be negated by using the "!" operator, as in "!text/plain", which matches
* all requests with a {@code Accept} other than "text/plain".
* <p><b>Supported at the type level as well as at the method level!</b>
* When used at the type level, all method-level mappings override
* this produces restriction.
* @see org.springframework.http.MediaType
*/
String[] produces() default {};
}
@RequestMapping to map URL
On the WWW, every information resource has a unified and unique address on the Internet. This address is called
URL (Uniform Resource Locator, Uniform Resource Locator), which is the uniform resource locator mark of WWW, refers to the network address.
The annotation @RequestMapping can be used in class definitions and method definitions.
Class definition: specify the preliminary request mapping, relative to the root directory of the web application;
Method definition place: further subdivide the request mapping, relative to the URL of the class definition place.
@RestController//That is the controller, and all methods in this class return json objects
@RequestMapping("/books")
public class BookController {
@Autowired
private BookService bookService;
@Autowired
private ShoppingService shoppingService;
@RequestMapping("/getBookByTypeId")
public ResultVo getBookByTypeId(Integer tid){
//Call the method of the service layer to query the book list based on the type id
List<Book> bookList = bookService.getBookByTypeId(tid);
return ResultVo.success("success",bookList);
}
.....
}
You can see that a **@RequestMapping("/books")** annotation is defined above the BookController class, so a common path will be added to the url address of the same annotation of all methods in this class: "/ books".
It specifies which URL requests can be processed for the Controller. Equivalent to an indicator, whenever the URL address is
http://localhost:8080/xxx/books/getBookByTypeId
Will be mapped toBookControllerofgetBookByTypeIdMethod.
Then, because this project uses axios to accept front-end requests, I didn’t understand that it did not appear in the project when I was just learning.
http://localhost:8080/xxx/books/getBookByTypeId
This URL, why the method can still be executed.

This article is just a summary of the learning process. It does not take into account the value difference between source code analysis and annotations. It is only derived from the simplest way, what is the use of this annotation, and how to use it.
A simple and simple understanding of then in promise Let's take a look at the difference between the following four Promises? Execute the first method: Perform the second method: Perform the third met...
To visit a certain page in web MVC, which page should we jump to, then we use the physical path of the page. If a page is in a certain folder, we will set the path there. The RequestMappi...
@Requestmapping understanding and basics @RequseMApping Understanding (Individual Understanding): The front-end controller in Springmvc removes the request to the browser (http: localhost: post / proj...
Let's first briefly describe what .NET, and a simple understanding of C#and one of them. 1.NET Overview .NET is the abbreviation of Microsoft.net, which is a technology based on the Windows platform. ...
1、Jquery Introduction to jQuery local download: Online introduction:http://www.bootcdn.cn/jquery/ Support all css2 selectors Most css3 options Cannot be quoted: this document window All click events a...
Reprinted at: https://blog.51cto.com/chaorenhuifei/1703026...
Assuming that the final exam is taken, the full score of the exam is 10, and five students have participated in the exam and scored 5, 3, 5, 2 and 8 points respectively. Now we need to sort their scor...
DispatcherServlet 1. custom class loader is running SpringMvc 2. Custom @Controller notes, annotations instead SpringMvc 2. Custom @RequestMapping notes, annotations instead SpringMvc 3.Controller pac...
Work hard to become a savvy female programmer! During this time, I have contacted AutoResetEvent. After I have a simple understanding, I made a small demo to introduce the basic usage. Welcome everyon...
Single case design pattern Hungry Chinese : A class can only create one object Privatization constructor Create an instance of a class inside the class, and be static Privatization object, invoked thr...