First, @RequestMapping IntroductionUse @RequestMapping in spring MVC to map a request, that is, to specify which URL requests the controller can handle, which is equivalent to configuring the servlet in Web. xmlThe mapping effect is consistent. Let's look at the source code for the Requestmapping annotation class first:@Target ({elementtype.method, elementtype.ty
A, @RequestMapping
Org.springframework.web.bind.annotation.RequestMapping
Annotation for mapping Web requests onto specific handler classes and/or handler. Provides consistent style between Servlet and Portlet environments with the semantics adapting to the concrete T.
@RequestMapping Note that it maps Web requests to specific processor classes and/or processor methods. It supports servlet and portlet envir
@RequestMapping annotations@RequestMapping is one of the most commonly used annotations in Spring WEB applications. This annotation maps HTTP requests to the processing methods of the MVC and REST controllers. This annotation can be used not only on methods, but also on classes, which represent all responses to requests in a class by using that address as the parent path, such as the ability to add a virtua
java.util.Collection;
@Controller//
From the above code, we can see that Bbtforumcontroller and the general class is no different, it does not implement any special interface, and thus is an authentic POJO. The magic wand that makes this POJO unique is the annotation of Spring MVC.
Two annotations were used at the ①, namely @Controller and @RequestMapping. In the article "using the Spring 2.5 note-driven IoC", I have pointed out that
@RequestMapping is an annotation used to process a request address mapping, can be annotated with a class, or annotated with a method on a class, an annotation with a class, a uniform identity representing the controller, usually a representation of a module, an annotation in a method, It means that a request is processed by that method.
@RequestMapping have several properties
One: Value property
Value re
usage of @RequestMapping annotations
@RequestMapping have the following attribute values:
1. @RequestMapping to map URLsAnnotation @RequestMapping can be used at the class definition and at the method definition.Class Definition: Specifies the initial request mapping, relative to the Web application's root directory;
The last article was built up Hello world. Today, the main thing to see is the use and functionality of requestmapping annotations. The previous article said that requestmapping can be used to map URLs, which can be used on classes or on methods.Requestmapping has the following properties: Value, method, params, headers, the following is a brief look at the function of the propertyValue: The URL of the map
1.1. @RequestMapping Mapping RequestSPRINGMVC use @RequestMapping annotations to specify which URL requests can be processed by the controller@requestMapping can be defined on classes and methodsPackage Com.ibigsea.springmvc.helloworld;import Org.springframework.stereotype.controller;import org.springframework.web.bind.annotation.RequestMapping; @Controllerpubli
Dispatcherservlet after a Web request is accepted, the request is sent to the different controller classes of the @controller annotation declaration. This scheduling process relies on various @requestmapping annotations declared in the Controller class and its handler methods. In Spring MVC, Web requests are mapped to handlers through one or more @requestmapping annotations declared in the controller class.
Tag: Mark GET request message specify MSU via MIL param efaultFirst look at the following code:@Controller @requestmapping ("/user") public class Userscontroller {@RequestMapping (value= "/findall") Private String FindAll () {return "index";}}Here are some simple ways to use the above notes:@Controller@Controller: Indicates that the class is a controller class. Suppose to use this annotation. This section n
Introduction:The rest style was used to develop the program in the previous time, but when the data was submitted in post and put, it was found that the server side did not accept the submitted data (the server-side parameter bindings did not add any annotations), and viewed the submission method as Application/json. And the server side of the data through Request.getreader () does exist in the browser submitted data. In order to find out the reason, the parameter binding (@RequestParam, @Reques
1.@RequestMappingSpring MVC uses @RequestMapping annotations to specify which URL requests can be processed by the controller, which can be labeled at the controller's class definition and method definition.@RequestMapping
At the class definition: Provides preliminary request mapping information. Equivalent to the root directory of the current WEB app
Method: Provides further subdivision mappin
The first part, overview/** mapping URLs to controller classes or handlers */@Target ({elementtype.method, elementtype.type})@Retention (Retentionpolicy.runtime)@Documented@MappingPublic @interface requestmapping {/*** Specify the mapping name* Support Controllers and methods* When both controllers and methods are supported, use "#" to separate*/String name () default "";/*** Path Mapping* The specified address can be a URI template, alias path, such
Continue to review @ requestmapping in spring MVC this time;
1) normal path[Code = "Java"]
@ Requestmapping (value = "/foos ")@ ResponsebodyPublic String getfoosbysimplepath (){Return "get some foos ";}[/Code]
Then try to use curl to requestCurl-I http: // localhost: 8080/spring-MVC/foos
2) specify requestmethod. Post[Code = "Java"]@ Requestmapping (value = "/foo
First, @RequestMapping[Email protected] In addition to modifying the method, can also modify the class(1) Modifier class: Provides preliminary request mapping information, relative to the root directory of the Web request(2) Modification method: Provide further subdivision mapping informationRelative to the URL at the class definition, if @requestmapping is not marked at the class definition, the URL marked
This article is very clear about spring's MVC @RequestMapping, Memo notes.
@Controller@RequestMapping ("/appointments")public class Appointmentscontroller {Private final AppointmentBook AppointmentBook;@AutowiredPublic Appointmentscontroller (AppointmentBook appointmentbook) {This.appointmentbook = AppointmentBook;}@RequestMapping (method = Requestmethod.get)Publ
@RequestMapping have the following attribute values:1. @RequestMapping to map URLsAnnotation @RequestMapping can be used at the class definition and at the method definition.class definition : Specifies the initial request mapping, relative to the Web application's root directory;method definition : Further subdivide the request map, relative to the URL at the cl
@RequestMapping Parameter DescriptionValue: The URL address of the request that defines the processing method. (Focus)Method: Defines the HTTP method type for processing methods, such as GET, POST, and so on. (Focus)Params: Defines the parameters that must be included in the requested URL. Or some parameters are not included. KnowHeaders: Defines the parameters that must be included in the request headers. Or some parameters are not included. Knowthe
@RequestMapping Parameter DescriptionValue: The URL address of the request that defines the processing method. (Focus)Method: Defines the HTTP method type for processing methods, such as GET, POST, and so on. (Focus)Params: Defines the parameters that must be included in the requested URL. Or some parameters are not included. KnowHeaders: Defines the parameters that must be included in the request headers. Or some parameters are not included. Knowthe
@RequestMapping modifier Classes @RequestMapping ("/SPRINGMVC")//This path is the path relative to the Web App root directory @controllerpublic classspringmvctest{privatestaticfinalstring success= "SUCCESS";/** * @RequestMapping In addition to the cosmetic method, you can also decorate the class * class definition: Provide preliminary request mapping information
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.