After upgarding to Struts 2.3.16.3 s:submit does n

2020-02-13 05:48发布

问题:

I recently upgraded to Struts 2.3.16.3 i.e the latest version of the release from 2.3.15.1

Now my submit buttons have stopped working when I use -

<s:submit align="center" action='Login_loginUser' value="Login"/>

My action mapping are as below -

<action name="Login_*" method="{1}" class="com.XXXX.XXXX.XXX.LoginAction">
    <result name="input" type="tiles">login.tiles</result>
    <result name="success">/jsp/common/success.jsp</result>
</action>

My struts.xml is as below -

<?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="true"/>
    <constant name="struts.action.extension" value="action"/>
    <include file="com/emsproject/system/sysconfig/login.xml"/>
 </struts>

My web.xml is as below -

<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>eSchoolMate</display-name>
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
        <init-param>
            <param-name>actionPackages</param-name>
            <param-value>com.mypackages</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>*.action</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/struts/*</url-pattern>
    </filter-mapping> 
    <listener>
        <listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
    </listener>
    <listener>
        <description>sessionListener</description>
        <listener-class>com.emsproject.action.common.SessionListener</listener-class>
    </listener>
    <context-param>
        <param-name>tilesDefinitions</param-name>
        <param-value>/WEB-INF/tiles.xml</param-value>
    </context-param>
    <welcome-file-list>
        <welcome-file>/jsp/common/index.html</welcome-file>
    </welcome-file-list>
    <servlet>
        <servlet-name>MyInfo</servlet-name>
        <servlet-class>com.mypackage.action.common.MyServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>MyInfo</servlet-name>
        <url-pattern>/eapp/*</url-pattern>
    </servlet-mapping>

</web-app>

I tried the exclude parameter change as mentioned in the release notes, but nothing seems to work.

If I change the s:submit to HTML input type button & call the action from the javascript as below -

function callLogin(){
    document.getElementById('sysForm').target="_self";
    document.getElementById('sysForm').action='/coms/common/Login_loginUser.action';
    document.getElementById('sysForm').submit();
}

This works fine but it would be a huge change throughout the application :(.

Not sure why the action mappings are not resolved in this version as everything works fine in Struts 2.3.15.1.

Any help would be much appreciated.

Thanks

回答1:

Many security fixes, including S2-016, occurred to the latest release, so some features or functionality is disabled by default. To enable the using action attribute in submit tag use the following constant in struts.xml

<constant name="struts.mapper.action.prefix.enabled" value="true"/>