Struts 2 工作流拦截器和没有输入结果的动作 [英] Struts 2 WorkFlow Interceptor and actions that do not have an INPUT result

查看:27
本文介绍了Struts 2 工作流拦截器和没有输入结果的动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我理解 Struts2 拦截器堆栈正确,工作流拦截器会查看验证拦截器是否报告了任何验证失败.如果它发现验证失败,则返回(默认情况下)Action.INPUT

如果是这种情况,如果正在执行的 Action 没有在其 struts.xml 配置中定义的 INPUT 结果会发生什么?

解决方案

如果它返回 INPUT,并且没有为此定义的结果(也没有一般结果),你会得到一个错误页面,内容类似于

>

 没有为 INPUT 类型和动作 <动作名称> 定义结果.

您可以定义一个将始终为INPUT"显示的常规页面,但更好的解决方案是,如果您有一个 validate() 方法,通常最好定义一个 INPUT 结果以返回.即使您没有明确进行任何验证,诸如传递给整数字段的非整数值之类的事情也可能导致该结果,因此最好对其进行定义.

If I understand, the Struts2 interceptor stack correctly, the workflow interceptor looks to see if any validation failures have been reported by the validation interceptor. If it finds that there have been validation failures, it returns ( by default ) Action.INPUT

If this is the case, what happens if the Action that is being executed does not have an INPUT result defined in its struts.xml configuration?

解决方案

If it returns INPUT, and there is no result defined for that (and no general result), you'll get an error page that says something like

 No result defined for type INPUT and action <action name>.

You can define a general page that will always be shown for 'INPUT', but the better solution is that if you have a validate() method, it's usually a good idea to define an INPUT result to go back. Even if you don't explicitly do any validation, things like a non-integer value being passed to an integer field can cause that result, so it's a good idea to define it.

这篇关于Struts 2 工作流拦截器和没有输入结果的动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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