Java Learning Notes (1)--strut2.3.24 Environment Building

Source: Internet
Author: User

1, open MyEclipse, add WebProject, name is TestStruts2

2. Configure the Tomcat environment.

1) Find tomcat6.x under Windows-Preferences--myeclipse--servers

2) Select Enable, browse to find the local Tomcat6 file location

3) Locate the Tomcat--conf--server.xml file and add it before the </Host> end tag

<path= "/teststruts2"  docBase= "E:\software\MyEclipseWorkSpaces\ Teststruts2\webroot "  reloadable=" true "/>

3. Introduction of JAR Package

4. Configure Web. xml

<?XML version= "1.0" encoding= "UTF-8"?><Web-appversion= "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>        

5, under the SRC path to establish struts.xml

<?XML version= "1.0" encoding= "UTF-8"?><!DOCTYPE struts Public "-//apache software foundation//dtd struts Configuration 2.3//en" "Http://struts.apache.or G/dtds/struts-2.3.dtd ">         <Struts>        < Packagename= "TestStruts2"extends= "Struts-default"namespace="">            <Actionname= "Login"class= "Com.test.action.LoginAction">                <resultname= "Success">/result.jsp</result>            </Action>       </ Package>    </Struts>

6. Create a class file under the SRC path

 Packagecom.test.action;ImportCom.opensymphony.xwork2.ActionSupport; Public classLoginactionextendsactionsupport{Private Static Final LongSerialversionuid = -74906200993380354l; PrivateString username; PrivateString password;  PublicString GetUserName () {returnusername; }     Public voidSetusername (String username) { This. Username =username; }     PublicString GetPassword () {returnpassword; }     Public voidSetPassword (String password) { This. Password =password; }         PublicString Execute ()throwsException {return"Success"; }}    

7, under the Webroot path new login.jsp, result.jsp to test

/** * login.jsp */  <form action= "Login" method= "POST" >       Username:<input type= "text" name= "username" ><br >      Password:<input type= "text" name= "password" >    <input type= "Submit" value= "Submit" >  </form>/*** result.jsp **/    username:${ Requestscope.username}<br>    Password:${requestscope.password}

Java Learning Notes (1)--strut2.3.24 Environment Building

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.