Configure the struts2 Development Environment on Eclipse Helios 3.6.2

Source: Internet
Author: User
1. Download eclipse
Log on to the eclipse official website to download http://www.eclipse.org/downloads/

I chose eclipse classic 3.6.2, 32-bit

2. Add web and Java EE development tools
Help-> install new software, select "Helios-http://download.eclipse.org/releases/helios" in the "Work with:" drop-down box (if not, you can add it yourself), and then in "Web, XML, and java EE development "select

-Eclipse Java EE Developer Tools
-Eclipse Web Developer Tools
-JST server adapters (required to create Apache Tomcat server)

3. Download Tomcat
Log on to Apache Tomcat official website to download http://tomcat.apache.org/

I chose Tomcat 7.0.14.

4. Add Tomcat plug-in
Http://www.eclipsetotale.com/tomcatPlugin.html

It seems that there is no official website or update site.
Download the package, decompress it, copy it to the plugin directory, and restart eclips.

5. Create a WEB Project
File-> New-> Project-> dynamic web project

6. Add the struts 2 class library
Login struts official website download http://struts.apache.org/downloads.html

I chose struts-2.2.3-lib.zip.
Download and decompress, copy the core class library required by struts 2 to the webcontent/WEB-INF/lib of the web Project
Commons-fileupload-1.2.2.jar
Commons-io-2.0.1.jar
Commons-lang-2.5.jar
Commons-logging-1.1.1.jar
Freemarker-2.3.16.jar
Javassist-3.11.0.GA.jar
Ognl-3.0.1.jar
Struts-core-1.3.10.jar
Xwork-core-2.2.3.jar

7. Create web. xml
I don't know why, there is no web. xml when the project is created, but it doesn't matter. We can build it ourselves.
File Location:/webcontent/WEB-INF/Web. xml
Content XML Code
 

  1. <? XML version = "1.0" encoding = "UTF-8"?>
  2. <Web-app id = "webapp_id" version = "2.4"
  3. Xmlns = "http://java.sun.com/xml/ns/j2ee" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
  4. Xsi: schemalocation = "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  5. <Display-Name> project name </display-Name>
  6. <Welcome-file-List>
  7. <Welcome-File> index.html </welcome-File>
  8. </Welcome-file-List>
  9. <Filter>
  10. <Filter-Name> struts2 </filter-Name>
  11. <Filter-class> org. Apache. struts2.dispatcher. filterdispatcher </filter-class>
  12. </Filter>
  13. <Filter-mapping>
  14. <Filter-Name> struts2 </filter-Name>
  15. <URL-pattern>/* </url-pattern>
  16. </Filter-mapping>
  17. </Web-app>
<? XML version = "1.0" encoding = "UTF-8"?> <Web-app id = "webapp_id" 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"> <display-Name> project name </display-Name> <welcome-file-List> <welcome-File> index.html </welcome-File> </welcome-file-List> <filter-Name> struts2 </filter-Name> <filter-class> Org. apache. struts2.dispatcher. filterdispatcher </filter-class> </filter> <filter-mapping> <filter-Name> struts2 </filter-Name> <URL-pattern>/* </url-Pattern> </filter-mapping> </Web-app>

8. Create struts. xml
File Location:/webcontent/WEB-INF/Classes/Struts. xml

Content XML Code
 

  1. <? XML version = "1.0" encoding = "UTF-8"?>
  2. <! Doctype struts public
  3. "-// Apache Software Foundation // DTD struts configuration 2.0 // en"
  4. Http://struts.apache.org/dtds/struts-2.0.dtd>
  5. <Struts>
  6. <Package name = "default" extends = "struts-Default">
  7. <Action name = "action_name" class = "package_name.class_name">
  8. <Result name = "success">./WEB-INF/JSP/success. jsp </result>
  9. <Result name = "failure">./WEB-INF/JSP/failure. jsp </result>
  10. </Action>
  11. </Package>
  12. </Struts>
<? XML version = "1.0" encoding = "UTF-8"?> <! Doctype struts public "-// Apache Software Foundation // DTD struts configuration 2.0 // en" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <package name = "default" extends = "struts-Default "> <action name =" action_name "class =" package_name.class_name "> <result name =" success ">. /WEB-INF/JSP/success. JSP </result> <result name = "failure">. /WEB-INF/JSP/failure. JSP </result> </Action> </package> </struts>

9. Create a server
File-> New-> Server
"Server type" I selected "Tomcat v7.0 server" and moved the new web project to "configured ".

In this way, the structure of struts 2 is basically set up.

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.