1.@Controller
@Controller for marking on a class, which is a class mark SpringMVC Controller object. The processor will distribute a scanning method using the annotation class, and the method detects whether the @RequestMapping annotations. @Controller controller only defines a class, a method using real @RequestMapping annotation process processor requests.
2.@RequsestMapping
RequestMapping is a process for annotation request address mapping, it can be used for class or method. For the class, all the methods in response to the request class are represented in the address as the parent path.
The return value will be analyzed by the parser view of actual physical view, for InternalResourceViewResolver view resolver, will make the following analysis:
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
In this manner returnVal + suffix obtained by actual physical view prefix +, then do forwarding operations;
RequsestMapping six attributes'
1、 value
value: Specifies the physical address of the request;
2、method;
method: method specifies the type of request, GET, POST, PUT, DELETE, etc.
3、consumes
consumes: submit a request specifying process of the content type (Content-Type), for example, application / json, text / html;
4、produces
produces: content type of the returned request only if the request header (the Accept) containing the specified type will return to type;
5、params
params: Specifies the request must contain certain parameter values, before allowing the processing method.
6、headers
headers: Specifies the request must contain certain specified header value, in order for this method to process the request.
3.@ResponseBody
The Java object into json object for ajax, the return is not a page but a certain format of data
4.valid: verifies the identification data
5. @ PathVariable: uri address of the reception parameters pass over
6.@SessionAttribute(names=("","","",....))
Forwards the data to change the role of Session
7.@RequestParam
@RequestParam request for map data to the parameter area parameter function processing method, use cases:
Without writing parameters are non @RequestParam will pass, will add parameters to pass. The same parameter names and pass over the parameter name.
Plus @RequestParam will be passed by a non @RequestParam (required = false) setting. Because the required default value is true, so by default will pass.
@RequestParam by @RequestParam ( "userId") or @RequestParam (value = "userId") specified parameter name.
@RequestParam by @RequestParam (defaultValue = "0") specified parameter default values
8. @ ExceptionAdvice: identifying an exception handler class
9. @ ExceptionHandler: a labeling method is a method of exception handling
10.InitBinder: processing time parameters
@InitBinder public void of an initBinder (ServletRequestDatabinder Binder) { // long as the page data from the format of yyyy-MM-dd will be converted to the Date type binder.registerCustomEditor (Date. Class , new new the CustomDateEditor ( new new the SimpleDateFormat ( "the MM-YYYY -dd " ), to true )); }