单一形式的多个支撑动作不起作用 [英] multiple struts actions on single form not working

查看:71
本文介绍了单一形式的多个支撑动作不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对提交"按钮进行操作,但是它不起作用.

I am trying to call an action on submit button but it is not working.

index.jsp

<s:form method="post" enctype="multipart/form-data">
    <s:file label="Upload Matrix.csv file:" name="file"></s:file>
    <s:submit value="Upload" action="uploadFile" cssClass="btn btn-info"></s:submit>
    <s:submit value="Update" action="fileData" cssClass="btn btn-primary" />
    <s:submit value="Show" action="sessionMatrix" cssClass="btn btn-primary"/>
</s:form>

struts.xml

<struts>
    <constant name="struts.enable.DynamicMethodInvocation" value="true" />
    <constant name="struts.devMode" value="true" />
    <constant name="struts.ui.theme" value="bootstrap" />

    <package name="default" namespace="/" extends="json-default,struts-default">

        <!-- cities populate -->
        <action name="ajaxAction" class="com.action.PopulateCities">
            <result type="json">/sessionMatrix.jsp</result>
        </action>

        <!-- JTable populate -->
        <action name="*Action" class="com.action.SessionRecordsAction"
            method="{1}">
            <result type="json">/sessionMatrix.jsp</result>
        </action>
        <action name="getJSONResult" class="com.action.SessionRecordsAction"
            method="list">
            <result type="json" />
        </action>

        <!-- to upload csvfile data into database -->
        <action name="fileData" class="com.util.UploadData">
            <result name="success">/sessionMatrix.jsp</result>
            <result name="error">/error.jsp</result>
        </action>

        <!-- to display data into table i.e ResultSet implementation -->
        <action name="sessionMatrix" class="com.action.SessMatrixAction">
            <result name="success">/exportSession.jsp</result>
            <result name="error">/error.jsp</result>
        </action>

        <!-- upload file -->
        <action name="uploadFile" class="com.action.FileUpload">
            <interceptor-ref name="defaultStack">
                <param name="fileUpload.maximumSize">10485760</param>
            </interceptor-ref>
            <result name="success">/dashboard.jsp</result>
            <result name="error">/error.jsp</result>
            <result name="input">/dashboard.jsp</result>
        </action>
    </package>
</struts>

我正在做的是调用每个动作类的execute方法,我甚至通过在动作标签以及<s:submit>标签中提及method属性来尝试.

What I am doing is calling execute method of of each action class I even tried by mentioning method attribute in action tag as well as <s:submit> tag.

推荐答案

自Struts 2.3.15.3起,您需要显式启用以下操作:后缀:

Since Struts 2.3.15.3, you need to explicitly enable the action: suffix with:

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

您可能还对阅读从表单调用不同操作的方式感兴趣.

You may also be interested in reading about the ways to call different actions from a form.

这篇关于单一形式的多个支撑动作不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆