Spring common annotations

 


1. Turn on the automatic scanning function before using the annotation, where the base-package is the package (including sub-packages) that needs to be scanned.
<context:component-scan base-package="cn.test"/>

1. @Controller is used to mark control layer components (such as actions in struts)
2. @Repository is used to mark data access components, namely DAO components.
3. @Service is used to annotate business layer components
4. The @RequestMapping annotation will map HTTP requests to the processing methods of MVC and REST controllers.
5. @ResponseBody, after using @responsebody, it will directly return json data.
6. @RequestParam to map request parameters
7. @component (instantiate ordinary pojo into the spring container, which is equivalent to <bean id="" class=""/> in the configuration file)
8. @PostContruct is the spring framework Annotation, adding the annotation to the method will execute the method when the project starts, or it can be understood as executing the method when the spring container is initialized.









BigDecimal defines a BigDecimal object:
BigDecimal total=BigDecimal.valueOf(0);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325000252&siteId=291194637