Eclipse uses STRUTS2 to develop Web applications to build quickly

Source: Internet
Author: User

Eclipse Downloads Java EE version, here with 4.5 (Mars).

TOMCAT8 decompression, set the JAVA_HOME environment variable.

Download the Lib package from the Struts2 website, struts-2.3.24-lib.zip, and unlock the jar pack that contains more than 100 of the jars we might use.

Download Struts2 Online example Pack, Struts-2.3.24-apps.zip, untie

Navigate to the blank example: Struts-2.3.24\apps\struts2-blank, the main content is in its Web-inf directory.

1. Create a new project, Dynamic Web project, use the next wizard, do not directly finish, and finally choose to build Web. Xml.

2. Copy the *.jar file under Web-inf\lib in the example to the Web-inf\lib directory of the new project.

3. Locate the Web. XML in the example Web-inf, and copy the following, under the Web-inf Web. XML node under the new project.

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

This means that struts2 will be used to intercept all access requests and how the request distribution needs to be configured in Struts.xml.

4. Locate the instance: \web-inf\src\java\struts.xml file and copy it to the SRC folder of the new project.

Comment out the contents of all <struts> tags and add the following:

< Packagename= "Default"namespace="/"extends= "Struts-default">        <Actionname= "H">            <result>/hehe.jsp</result>        </Action></ Package>

This defines the relative url:.../h or .../h.action will use hehe.jsp as the output response.

5. Create the hehe.jsp file and add it to the,<body> tag in the automatically generated HTML:

6. Save all files and confirm that no error has been filed. Servers Select Tomcat8, right-click, start, see Tomcat is started.

Browser input: http://localhost:8080/project name/h

You should be able to see the output of the JSP page.

Eclipse uses struts2 to develop web App quick build

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.