Home > database >  Commonly used annotations of SSM framework
Commonly used annotations of SSM framework

Time:09-29

A. Mybatis

1 configuration query one-to-many and many-to-many query annotation pattern mapping relationship:
@ Results: declare mapping configuration Value attribute receive @ the Result array
@ Result: configure the mapping relationship between
The id attribute (Boolean) statement whether the primary key configuration
The Property attribute object attribute of the
The Column attribute query field name

2. Spring

2 to create the object to the annotation of the spring container management
@ Component (value="id" https://bbs.csdn.net/topics/id
@ Controller (value="id" https://bbs.csdn.net/topics/id web layer
@ Service (value="id" https://bbs.csdn.net/topics/id Service layer
@ Repository (value="id" https://bbs.csdn.net/topics/id dao layer
That need to be configured to the class on the Value attribute specifies a unique identifier

3 attribute dependency injection annotations
The @autowired
Note: the default in accordance with the type (interface) finding objects from the container and injection can also be to attribute name as a unique identifier finding objects from the container and injection
@ the Qualifier (value="id" https://bbs.csdn.net/topics/id the value attribute can be according to the id uniquely identifies injection
@ Value
Description: basic data types can also be injected into injection by the spring container management properties the contents of the file

4 life cycle related annotation
@ Scope
Description: the role of the object the Value attribute (singleton | prototype)
@ PostConstruct
Description: configuration on the methods used to configure initialization method
@ PreDestory
Description: configuration on the methods used to configure destroy method


5 configuration class is used to replace the notes of the XML configuration files
@ Configuration: statement Configuration class
@ ComponentScan: open the package scanning
@ PropertySource: properties configuration file to the spring container management
@ Import: the introduction of other configuration class
@ Bean: configuration to the method, it shows that this method returns a value to the spring container management

6 springTest related annotation
@ Runwith (SpringJunit4ClassRunner. Class) statement provided by the spring class loading configuration file
@ ContextConfiguration statement of spring's configuration information
Locations of XML configuration file Classes attribute configuration class bytecode

7 AOP related annotation
@ Aspect declaration section
@ PonitCut define public point configuration on the empty methods
The value attribute reference point expression: the method name ()
Configure notification type:
@ prior notice Before
@ AfterReturnint rear notice
@ AfterThrowing abnormal notice
@ After final notice
@ Around Around notice
@ EnableAspectJAutoProxy open support for AOP annotations used for pure annotations using

Eight transactions related annotation
@ Transactional need transaction on the class or method of using the configuration transaction
@ EnableTransactionManagement used pure annotations on behalf of open support for annotations transaction

3. For springmvc

9 @ RequestMapping ("/user ") to be browsing access path and the current method of mapping
@ RequestHeader to request header information
@ CookieValue get the jsessionID cookie
@ RequestBody configuration to the method parameter, which indicates that converting the json string to a Java object
@ ResponseBody configuration to the method return value, which indicates that the object into a json string
@ RequestBody configuration to the method parameter, which indicates that object json string can be converted to
@ SessionAttributes (value={} "username" https://bbs.csdn.net/topics///that represent the current all the methods in the class as long as it is operating the specified parameters model object is to save a session field
@ ModelAttribute (" aaa ") is added to the Model element

10 restFul programming code requirements:

Determine the parameters for the address (id) : how to set the path format {id}
Determine how to get to the address parameter (id) on the method parameters using annotations: @ PathVariable (value="https://bbs.csdn.net/topics/id")
On a certain way of submission specified @ RequestMapping (value="https://bbs.csdn.net/{idddd}. HTML", method=RequestMethod. GET) applies only to GET submitted

CodePudding user response:

Very detailed, but advice into blogs,

CodePudding user response:

Advice into blogs, but very detailed,

CodePudding user response:

Thanks for sharing the

CodePudding user response:

Thanks for sharing, a great help
  • Related