Struts2 framework of Hello World

Source: Internet
Author: User

Struts HelloWorld

First Step guide Jar package

Commons-fileupload-1.2.2.jar "File Upload related package"

Commons-io-2.0.1.jar "input and output related packages"

Struts2-core-2.3.4.1.jar "struts2 core Feature Pack"

Xwork-core-2.3.4.1.jar "Xwork Core Pack"

Ognl-3.0.5.jar "OGNL expression feature Support table"

Commons-lang3-3.1.jar "struts extension to Java.lang package"

Freemarker-2.3.19.jar "Struts tag Template Library jar file"

Javassist-3.11.0.ga.jar "struts-to-bytecode processing related jar"

Step two configure Web. xml

<!--Introducing the Struts core filter-<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>

The third step is to develop an action processing request

 Package com.struts.action; Import Com.opensymphony.xwork2.ActionSupport;  Public class extends actionsupport {        //  processing request public        throws  Exception {            System.out.println ("Access to Action, processing request");            System.out.println ("Call service");             return "Success";        }}

Fourth Step configuration Struts.xml file is placed under SRC

<?XML version= "1.0" encoding= "UTF-8"?><!DOCTYPE struts Public "-//apache software foundation//dtd struts Configuration 2.0//en" "Http://stru Ts.apache.org/dtds/struts-2.0.dtd "><Struts>    < Packagename= "xxxx"extends= "Struts-default">        <Actionname= "Hello"class= "Com.struts.action.helloaction"Method= "Execute">            <resultname= "Success">/myjsp.jsp</result>        </Action>    </ Package> </Struts>

Well, struts HelloWorld is finished.

Struts2 framework of Hello World

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.