升级到 Struts 2.3.16.3 s:submit 后不起作用

After upgarding to Struts 2.3.16.3 s:submit does not work(升级到 Struts 2.3.16.3 s:submit 后不起作用)

本文介绍了升级到 Struts 2.3.16.3 s:submit 后不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近升级到 Struts 2.3.16.3,即 2.3.15.1 的最新版本

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>

我的 struts.xml 如下 -

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>

我的 web.xml 如下 -

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.

如果我将 s:submit 更改为 HTML 输入类型按钮 &从 javascript 调用操作如下 -

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 :(.

不知道为什么这个版本没有解析动作映射,因为在 Struts 2.3.15.1 中一切正常.

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

任何帮助将不胜感激.

谢谢

推荐答案

许多安全修复,包括 S2-016,出现在最新版本中,因此默认禁用某些特性或功能.要在 submit 标记中启用 using action 属性,请在 struts.xml

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

这篇关于升级到 Struts 2.3.16.3 s:submit 后不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:升级到 Struts 2.3.16.3 s:submit 后不起作用

基础教程推荐