Spring2.5 before we did that by implementing Control interface or implementation to define our processor class.
Spring2.5 Note Processor support was introduced, @controller and the @requestMapping annotations Define our classes and provide a powerful set of annotations:
Need to pass processor mapping
defaultannotationhandlermapping and Processor adapters Annotationmethodhandleradapter to turn on support @Controller and @RequestMapping the annotated processor.
@ Controller used to identify the processor class
@RequestMapping: Mapping rules for request-to-processor functional methods;
@RequestParam: Bind the request parameter to the method parameter of the processor function processing method;
@ModelAttribute: The binding of the request parameter to the command object;
Spring3.0
use of a new handlermapping and the Handleradapter Support @Controller and the @RequestMapping Annotation Processor
the new @Contoller and @requestmapping annotation support classes: Processor mapping requestmappinghandlermapping
and Processor Adapters requestmappinghandleradapter combination to replace Spring2.5 processor mapping defaultannotationhandlermapping and processor adapter Annotationmethodhandleradapte R
Let's take a look at the basic annotations below
The mapping of the processors is assigned to the following
- URL Path mapping: Using URL mapping request to the processor's functional processing method;
- Request Method Mapping Qualification: If the Limit function processing method only handles GET request;
- Request Parameter Mapping Qualification: If the qualification only deals with " ABC "request parameter request;
- Request Header Mapping Qualification: If the limit is only processed " Accept=application/json "Request
implementation of the controller 1 defining the processor @Controller
@Controller///① to declare a Pojo class as processor @requestmapping ("/examqueryquestion")///② request URL-to-processor feature-handling method mapping public Classqueryquestioncontroller {}
1.1 Narrowing request mapping @RequestMapping
http://192.168.24.9:8080/ Itoo-exam-questionbankmanage-web / examqueryquestion / toquestiontypesexcel
@Controller // / ① will a POJO class is declared as a processor
@RequestMapping ("/examqueryquestion") // /Generic Request prefix
Public class Queryquestioncontroller {
@RequestMapping ("/toquestiontypesexcel")
Public Stringtoquestiontypesexcel (HttpServletRequest request,
HttpServletResponse Resposne) {
return "/examqueryquestion";
}
}
can be passed in a POJO Place on class @Controller or @RequestMapping , you can put a POJO class becomes processor;
2Spring configuration file spring-mvc.xml
<!--Spring3.1 start annotations handlermapping-<bean
3 Configuration of the view parser
or use the previous Org.springframework.web.servlet.view.InternalResourceViewResolver .
4 configuration of the processor
simply register the processor implementation class with the spring configuration file, spring defaultannotationhandlermapping or requestmappinghandlermapping @Controller or Span lang= "en-US" style= "FONT-SIZE:18PX; Font-family:calibri "> @RequestMapping auto discovery.
Summary:
This content is A small part of Spring, its content is a simple injection method, no longer have the configuration file, Of course, the pre-learning configuration file Method injection is also the same , the basic understanding is not much what, simple record two ways of learning.
Introduction to SPRINGMVC Controller annotations