Use Eclipse to tune the first Struts2 example

Source: Internet
Author: User

The first step is to create a new Web project, add jsp,login.jsp and result.jsp, and note that the form's action attribute is "*.action"

The second step, will be 5 struts of the package (Commons-logging-1.0.4.jar,freemarker-2.3.8.jar,ognl-2.6.11.jar,struts2-core-2.0.12.jar, Xwork-2.0.6.jar), copied to Web-inf/lib

Step three, create two XML, a web.xml, add content:

<filter>

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

A struts.xml is added below SRC, which reads:

<?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= "EA" extends= "Struts-default" >

<action name= "Login" class= "Com.test.action.LoginAction" >

<result name= "a" >/result.jsp</result>

</action>

</package>

</struts>

Step fourth, set up the Action,com.test.action.loginaction class, with two properties consistent with the page name (note that there is no need for a name to correspond to the page, only the Set,get method is required for the page name), The action class has an Execute method that returns a page

for the name of the corresponding value of result.

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.