Search code examples
javastruts-configstruts-1

Need understanding about struts-config.xml file


Let's say i have a struts-config.xml file, putting action tag only :

</action>
            <action path="/import"
                type="com.app.console.CSVAction"
                    scope="session"
                    name="formName"
                    input="/example.jsp"
                    validate="true">
            <forward name="success" path="/myAction.do?subAction=import"/>
 </action>
  1. What is the role of path attribute, will it call reset method of myAction also.
  2. What if i put redirect parameter to true.

I am asking this question because in my code.. the actionform is getting reset always(where all bean properties will be reset) corresponding to myAction.do, when i call the action myAction.do above.

Please provide the detailed explanation.


Solution

    • The path attribute defines the URL of the action.
    • Why would it call an arbitrarily-named action method?!
    • Oh you mean your action form. reset is always called by the framework, as per the documentation. Reset is almost only for initial checkbox values to work around how HTTP/clients handle unchecked checkboxes.
    • It will redirect to the forward.

    Please consider reading some Struts 1 documentation.