struts action mapping action input attribute
Asked Answered
S

5

22

I am a noob when it comes to Java and Struts ( I feel like .Net boy in Java world ).

What is the input attribute on the action element used for? So in the example below the input is someinput.jsp.

<action path="/somepath" 
        type="SomeAction" 
        name="SomeForm" 
        scope="session"
        input="someinput.jsp">
Sabayon answered 11/7, 2011 at 1:9 Comment(0)
B
31

If the form bean SomeForm returns validation errors, it will return the page someinput.jsp. To quote the corresponding DTD:

Valid only when "name" is specified. Required if "name" is specified and the input bean returns validation errors. Optional if "name" is specified and the input bean does not return validation errors.

Birth answered 11/7, 2011 at 1:39 Comment(0)
B
4

Struts will forward the user to the page/action specified in the input attribute if validation fails on the form specified in the name attribute.

Bly answered 11/7, 2011 at 1:12 Comment(0)
B
1

Notwithstanding the above, it is also possible in your action execution (whether it is a single unit of action, or multiple units of action), to specify the result, i.e. SUCCESS, FAILURE, or INPUT.

Bicorn answered 11/7, 2011 at 1:34 Comment(0)
S
0

Struts validator plug-in will intecept the created form bean instance from the view and does validation before going to controller and if the data is against the end-user validation rules then errors object is digested in input attribute view which is specified as a value

Stow answered 11/3, 2014 at 9:27 Comment(0)
T
0

It's for redirection to the jsp in the input attribute. But in your Action controller you need to specify mapping.getInputForward() instead of mapping.findForward().

Struts-config file:

<action input="test.jsp"
        name="testActionForm"
        path="/test" 
        scope="session"      type="package.TestActionController">
</action>

Action Controller:

public ActionForward doMethod(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
        return mapping.getInputForward();
}
Thrower answered 12/2, 2015 at 16:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.