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.