Web application adds struts2 support

Edit the web.xml configuration file of the Web application and configure the core Filter of Struts2. The following is a code snippet of the web.xml configuration file that adds the core Filter configuration of Struts2.

<!-- Define the core filter of struts2 --> 
  < filter > 
      < filter-name > struts2 </ filter-name > 
      < filter-class > org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </ filter-class > 
  </ filter > 
  <!-- Let the core filter of struts2 intercept all requests --> 
  < filter-mapping > 
      < filter-name > struts2 </ filter-name > 
      < url-pattern > /* </url-pattern>
  </filter-mapping>

Copy the struts.xml file in the WEB-INF\classes path of the struts2-blank.war archive in the apps directory of the Struts 2 decompression directory to
the src directory of the web application (all files in the src directory will be copied when the application is compiled). file into the classes
directory ), and modify the file to the following format:

<?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>
    <!-- 基础配置 -->
    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="true" />
    <constant name="struts.i18n.reload" value="true" />  
    <constant name="struts.configuration.xml.reload" value="true" ></constant>
    
    <package name="default" namespace="/" extends="struts-default">

        <action name="*">
                <result>/WEB-INF/content/{1}.jsp</result>
        </action>
    </package>


    <!-- Add packages here -->

</struts>

After the above 2 steps, the basic functions of Struts2 can be used in a Web application

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324956678&siteId=291194637