Let your Java Web program have struts capabilities.

Source: Internet
Author: User

First download the corresponding version of the struts package, and then import the required jar package in the Lib directory, if you do not know can be fully imported (later to understand the functionality of each package can be added on demand).

The Web. xml file is then modified to add a filter and a mapping table, typically adding filters to all URLs.

The last is to add the CONFIG. struts.xml file, which is generally a file or struts.propertites.

Here is an example of the struts2.3.16 version:

Add a filter under Web. Xml. Code:

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

Then just add the Struts.xml file under SRC and directory, if not, create a new. and add code

<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE struts Public "-//apache software foundation//dtd struts Configuration 2.3//en" "http://struts.apache.org/dtds/ Struts-2.3.dtd "><struts>    <!--This is a constant, which is the setting of the struts configuration constants. --    <constant name= "Struts.enable.DynamicMethodInvocation" value= "false"/> <constant    name= " Struts.devmode "value=" true "/>    <!--This is the package, which is as differentiated--<package name=" Package1 "extends="    Struts-default ">    <!--here to map action--    <action name=" Login "class=" action.loginaction "method= The "print" >    <!--call method returns the result corresponding to the calling page--    <result name= "Success" >    /index.jsp    </result >    </action>    </package>
</struts>

  

Let your Java Web program have struts capabilities.

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.