Struts2.2.3 madatory jar packages:
Struts2-core-2.2.3.jar
Xwork-core-2.2.3.jar
Commons-fileupload-1.2.2.jar
Commons-io-2.0.1.jar
Commons-lang-2.5.jar
Commons-logging-1.1.1.jar
Freemarker-2.3.16.jar
Javassist-3.11.0.GA.jar (This one's location is different. You need use winrar to open one of files in apps (struts2-blank.war). it is in the src dictory)
Ognl-3.0.1.jar
Errors:
Java. lang. NoClassDefFoundError: org/apache/commons/io/FileUtils
Lack of commons io package
Java. lang. NoClassDefFoundError: org/apache/commons/lang/StringUtils
Lack of commons lang package
Java. lang. ClassNotFoundException: ipvsist. ClassPool
Lack of javassist package
The following is an example:
Login. jsp inputs username and password, then show them in result. jsp
Login. jsp
<Body>
<Form action = "login">
Username: <input type = "text" name = "username"/> <br/>
Password: <input type = "password" name = "password"/> <br/>
<Input type = "submit" value = "submit"/>
</Form>
</Body>
Result. jsp
<Body>
Username: $ {requestScope. username} <br>
Password: $ {requestScope. password} <br>
</Body>
Server part:
Package com. junxu. struts2;
Public class LoginAction
{
Private String username;
Private String password;
Public String getUsername ()
{
Return username;
}
Public void setUsername (String username)
{
This. username = username;
}
Public String getPassword ()
{
Return password;
}
Public void setPassword (String password)
{
This. password = password;
}
Public String execute ()
{
Return "success ";
}
}
Struts. xml
<? 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 = "struts2" extends = "struts-default">
<Action name = "login" class = "com. junxu. struts2.LoginAction">
<Result name = "success">/result. jsp </result>
</Action>
</Package>
</Struts>
Web. xml
<? Xml version = "1.0" encoding = "UTF-8"?>
<Web-app version = "2.5"
Xmlns = "http://java.sun.com/xml/ns/javaee"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemaLocation = "http://java.sun.com/xml/ns/javaee
Http://java.sun.com/xml/ns/javaee/web-app_2_5.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>
This article is from the blog "stupid bird first fly ".