Configuring Spring Applications under Eclipse

xiaoxiao2021-03-06  45

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:

Spring

Org.springframework.web.servlet.dispatcherServlet

contextconfiglocation

/web-inf/application.xml

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 is "Spring", the configuration file name is: springt-servlet.xml)

1

Spring

*. do

At this time, the Spring profile (here is scheduled to spry-servlet.xml) as follows:

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.

Hello World

When there is a "", "" is specified, and " " will be used below after specifying "bean-name". "To specify the value of the properties of this bean format," ID "in" "must be consistent with the" bean-name "specified above.

liang

LoginAction

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:

TYPE = "Org.springframework.web.struts.delegatingactionProxy"

Name = "loginform">

ClassName = "Org.springframework.web.struts.contextloaderplugin">

Value = "/ Web-inf / Spring-servlet.xml" />

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 " " to specify the Spring profile.

The Spring-Servlet.xml configuration file is as follows:

"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.

Hello World

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

http://java.sun.com/jstl/core /web-inf/c.tld Such a label is first declared.

转载请注明原文地址:https://www.9cbs.com/read-71576.html

New Post(0)