Configuring Spring Applications under Eclipse
One. About Spring environmental configuration issues.
The needed package (except for the basic Java web development environment (such as JDK, Tomcat): Spring-framework, Jakarta-Struts (behind the part of the combination of Spring with Struts).
two. About Spring's basic profile (I personally feel, after learning development framework, after understanding its design ideas, the configuration file setting is a key. After successful construction, the programming is unfair than everyone. )
When establishing a simple Spring project, the web.xml file is as follows:
XML Version = "1.0" encoding = "UTF-8"?>
Org.springframework.web.servlet.dispatcherServlet
servlet-class>
init-param>
One of the above boxes is used to specify the Spring profile (can be any name, if above), or if the spring is not written, Spring's configuration file default name is: "servlet-name>" name -Servlet.xml . (The value of
servlet>
servlet-maping>
web-app>
At this time, the Spring profile (here is scheduled to spry-servlet.xml) as follows:
XML Version = "1.0" encoding = "UTF-8"?>
When configuring properties (including properties of the bean format) in the bean, the bean must define the same attribute value as the Name name of Property, and requires the Getter and Setter methods of this property value.
Property>
When there is a "", "" is specified, and "
Property>
bean>
Property>
bean>
prOPS>
Property>
bean>
beans>
When establishing the Spring Struts project, the web.xml file is established in accordance with the specifications of the Struts project, wherever it is said, at this time, Struts-config.xml is as follows:
XML Version = "1.0" encoding = "UTF-8"?>
TYPE = "Org.springframework.web.struts.delegatingactionProxy" Name = "loginform"> action> action-mappings> ClassName = "Org.springframework.web.struts.contextloaderplugin"> Value = "/ Web-inf / Spring-servlet.xml" /> plug-in> Struts-Config> In this configuration file, since Spring is used to manage Struts Action, there are two places to pay attention to: 1. Action's "type" points to the class defined in Spring to process the Action, not the action written. 2. Add a " The Spring-Servlet.xml configuration file is as follows: XML Version = "1.0" encoding = "UTF-8"?>
"http://www.springframework.org/dtd/spring-beans.dtd"> Singleton = "false"> The bean here corresponds to the action in struts-config.xml, and Name is consistent with the Action of Action in Struts-Config.xml. Property> bean> beans> three. The small problem that should be paid attention to: 1. To put the package you need to use in the development, the TLD file is placed in the lib, the TLDS folder in Web-INF. 2. Be sure to use the tags such as struts, spring, jstl, etc. Below