Simple setup of the SSH framework 1 (establishment of struts)
Source: Internet
Author: User
1. Open myeclipse and create a web project named testssh.
2. paste the six jar packages required by struts under the Web Lib. (The jar package is included in the attachment)
3. Configure struts filter in Web. xml.
The Code is as follows:
<? XML version = "1.0" encoding = "UTF-8"?>
<Web-app 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>
// The above lines of code are copied from the struts-core-2.0.8.jar under the referenced libraies struts-default.xml
<! -- Start struts configuration -->
<Filter>
<Filter-Name> mystruts </filter-Name> <! -- The name of the filter can be written at will -->
<Filter-class> org. Apache. struts2.dispatcher. filterdispatcher </filter-class>
</Filter>
<Filter-mapping>
<Filter-Name> mystruts </filter-Name> <! -- The name of the filter above must be the same -->
<URL-pattern>/* </url-pattern>
</Filter-mapping>
<! -- End struts configuration -->
4. Create a package named action under SRC and create a class named testaction. Java in this package to inherit actionsupport
The Code is as follows:
Package action;
Import com. opensymphony. xwork2.actionsupport;
Public class testaction extends actionsupport {
/**
*
*/
Private Static final long serialversionuid = 6241935194381649471l;
Public String execute () throws exception {
System. out. println ("struts ========================= "); // This statement is printed on the console,
Return "success ";
}
}
5. Create a struts. XML Code under SRC as follows:
<? 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 = "login" class = "Action. testaction">
<Result name = "success"> index. jsp </result>
</Action>
</Package>
</Struts>
6. <body> in index. jsp is the page for testing the Struts framework. </body>
Write a sentence,
7. deploy the project to Tomcat, start Tomcat, open the browser, and enter http: // localhost: 8080/testssh/login in the address bar. action will display a page that says this is the page to test the Struts framework.
At this point, the Struts framework has been set up.
Later, we will introduce how to add the Hibernate and spring frameworks based on struts.
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.