Today, we set up an SSH + DWR framework. In fact, the SSH framework configuration is similar to the previous one. It mainly uses annotations to implement the C and M layers. below is the Web. xml configuration.
Note that if you want to use the struts2 annotation, you must add the actionpackages parameter When configuring the filter. this parameter is used to set the path of the struts2 container to search for the action package.
The following is the
Package, if 4.2 also need to introduce the AOP package(2), introduce the constraint file spring-context-4.2.xsd(3), open note driver@Resource Note: Put on a property or on a set method. You do not need to provide a set method. The default is based on the name, if not according to the interface and implementation of the relationship between the class, if there are multiple implementation classes need to specify the name@Autowired Note: Placed on the p
is fine. As for why is it configured in spring. XML, thank you.
@Component("service")public class BaseServiceImpl implements BaseService{private @Resource BaseDao dao;public int count(Class entity) {returndao.count(entity);}public
Next, how does the struts2 action reference the service and how to use the struts2 annotati
It's so hard to find.Original address: Https://dzone.com/articles/spring-annotation-processing-how-it-worksIf you see an annotation, there must is some code somewhere to process it.One of the things I emphasize when I teach Java classes was the fact that annotations was inert. In other words, they is just markers, potentially with some properties, but with no beh
scan needs to be configured in two configuration files, and I have done so several tests:(1) Only configured as follows in Applicationcontext.xml Startup is normal, but no requests are intercepted, in short, @controller failure(2) Configure the above configuration only in Spring-servlet.xmlStart normal, the request is normal, but the thing is invalid, that is, cannot roll back(3) Configure the above information in both Applicationcontext.xml and
logic layer
@ Repository: Persistence Layer
2. Annotations exist.
Java code@ AutowiredUserService userService;
@ AutowiredUserService userService; 3. Corresponding setter Method
Java codePublic void setUserService (UserService userService ){This. userService = userService;}
Public void setUserService (UserService userService ){This. userService = userService;} 4. If it is an interface or an abstract class, the class must be unique; otherwise, an error occurred while creating the instance.
J
Spring uses annotations to configure C3P0 connection pooling and DAO use JdbcTemplate
1.Spring Configuration c3p0 Connection pool
Step one: Import the C3P0 jar package
Jar Package Download
Step Two: Create the spring configuration file and configure the connection pool
This is what we write when we write the C3P0 connection pool:
Combopooleddatasource da
Note implementation of Bean management
Classpath Scanning and component management
Automatic detection of classes and registration of beans
@Component, @Repository, @Service, @Controller
@Required
@Autowired
@Qualifier
@Resource
(i) Classpath scanning and component management
Starting with Spring3.0, the Spring Javaconfig project offers a number of feature
. @InitBinder is commonly used for controller to HTML encode all incoming strings so that form can be passed, preventing XSS attacks, such as converting a date of a string type to a date type @EnableCaching Note Automation configures the appropriate cache manager. @EnableWebSecurity annotation Opens the function of spring security, integrating websercrityconfigureadapter. The @SringBootApplication is equiva
write the annotations, spring will automatically help you find the appropriate bean, the corresponding annotation markup meaning, do not understand, you can check the @service, @Controller, @Entity and so on.
Package Com.mvc.controller; Import java.util.List; Import Javax.servlet.http.HttpServletRequest; Import Javax.servlet.http.HttpServletResponse; Import Org
, Commonannotationbeanpostprocessor, Persistenceannotationbeanpostprocessor, requiredannotationbeanpostprocessor These processing classes, can beConfigure the implicit configuration into the spring container. These are the processing of dependency injections, as well as the processing of production bean annotations (@Component, @Controller, @Service, @Repository): Package= "Net.aazj.service,net.aazj.aop"/>t
Spring mvc Annotation
Starting from Spring 2.5, Spring provides the function of completely configuring beans based on Annotations and assembling beans. We can use annotation-based Spring IoC to replace the original XML-based confi
://www.springframework.org/schema/tx/spring-tx.xsd "> Beans>3. Create an implementation class Public Interface UserService { publicvoid Save (); Public void update (); Public void Delete ();}@Service (value= "UserService") Public classUserserviceimplImplementsUserService {@Override Public voidSave () {//TODO auto-generated Method StubSYSTEM.OUT.PRINTLN ("Business layer: Save
,inch); }}Service Interface:// transfer case Business layer interface Public Interface Accountservice { /* * * @param out: Transfer account * @param in : Transfer account * @param Money: Transfer amount */ public void -In , Double money);}Service Implementation class:Using @transactional things annotations, you can use different annotat
Bean Management (Annotation method)1. Add a dependency package for annotations: Spring-aop.jar2, the introduction of the configuration of spring XML file (check the official source)3. Open the scanning of annotations4, in the injected class using annotation injection: @Component ("id")To distinguish between three-tier
Detailed description of the annotation-driven event listener in the Spring 4.2 frameworkDetailed description of the annotation-driven event listener in the Spring 4.2 framework
Event interaction has become an indispensable part of many applications. The Spring framework prov
Introduction: Spring's dependency configuration is loosely coupled to the kernel itself of the spring framework. However, until Spring 3.0, using XML for dependency configuration is almost the only option. The advent of Spring 3.0 has changed this situation by providing a series of annotations to dependency injection, which makes the
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.