Multiple location actions on the same form do not work

I'm trying to call an action on a submit button but it doesn't work.


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



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

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

        <!-- 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>

        <!-- 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>

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


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



source to share

2 answers

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

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


You may also be interested in learning about ways to invoke various actions from a form .



You missed the action attribute in the tag <s:form>

. Use action attribute in your code like

    <s:form method="post" enctype="multipart/form-data" action="actionName">




All Articles