Java struts 动作映射动作输入属性

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6644861/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-16 08:34:33  来源:igfitidea点击:

struts action mapping action input attribute

javastruts-config

提问by rabs

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

当谈到 Java 和 Struts 时,我是个菜鸟(我觉得自己就像 Java 世界中的 .Net 男孩)。

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

action 元素的 input 属性是做什么用的?所以在下面的例子中,输入是 someinput.jsp。

<action path="/somepath" 
        type="SomeAction" 
        name="SomeForm" 
        scope="session"
        input="someinput.jsp">

采纳答案by Ken Chan

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

如果表单 beanSomeForm返回验证错误,它将返回 page someinput.jsp。引用相应的 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.

仅在指定“名称”时有效。如果指定了“name”并且输入 bean 返回验证错误,则是必需的。如果指定了“name”并且输入 bean 不返回验证错误,则可选。

回答by highlycaffeinated

Struts will forward the user to the page/action specified in the inputattribute if validation fails on the form specified in the nameattribute.

input如果name属性中指定的表单验证失败,Struts 会将用户转发到属性中指定的页面/操作。

回答by Oh Chin Boon

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.

尽管如此,也可以在您的动作执行中(无论是单个动作单元还是多个动作单元)指定结果,即SUCCESSFAILURE、 或INPUT

回答by feel good and programming

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

Struts 验证器插件将从视图中接收创建的表单 bean 实例并在进入控制器之前进行验证,如果数据违反最终用户验证规则,则在输入属性视图中消化错误对象,该对象被指定为一个值

回答by Ahmed MANSOUR

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

它用于重定向到输入属性中的jsp。但是在你的 Action 控制器中你需要指定 mapping.getInputForward() 而不是 mapping.findForward()。

Struts-config file:

Struts 配置文件:

<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();
}