Build STRUTS2 Environment
The big aspect is divided into three steps:
1. Add a jar Package
2. Configuring Struts2 in Web. xml
3. Add the struts2 configuration file Struts.xml
Here are the detailed steps:
1. Create a new dynamic Web Project
2. Download struts on the Struts official website. The struts 2.3.30 are used here. http://struts.apache.org/
Open the downloaded package, go to apps, unzip the Struts2-blank package. Blank refers to an empty package, which is the most classic (most commonly used) package used in the development of STRUTS2.
Copy the Lib package inside the Struts2-blank\web-inf into the Lib package in the new project's webcontent (some habits are called webroot).
3. Copy the Web. XML under Struts-2.3.30\apps\struts2-blank\web-inf to the Web-inf directory of your project. Configure the filter filters for STRUTS2 in Web. Xml.
<?XML version= "1.0" encoding= "UTF-8"?><Web-appID= "Webapp_9"version= "2.4"xmlns= "HTTP://JAVA.SUN.COM/XML/NS/J2EE"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "Http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <Filter> <Filter-name>Struts2</Filter-name> <Filter-class>Org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</Filter-class> </Filter> <filter-mapping> <Filter-name>Struts2</Filter-name> <Url-pattern>/*</Url-pattern> </filter-mapping> </Web-app>
3. Copy the Struts.xml file to the SRC directory of your project in the Struts-2.3.30\apps\struts2-blank\web-inf\src\java or web-inf\classes directory.
If there is a warning, copy the address of line 4th. In Eclipse Windows-->preferences-->xml Select: XML Catalog, then add ...
When you turn it off and on, you'll be prompted to write something.
Eclipse Builds STRUTS2 Environment