Struts2.2.3 configuration

Source: Internet
Author: User

 

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

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.