Avoid Return “input” Automatically in Struts

Deadly 提交于 2019-11-29 12:29:59

If your Action can return an input result, then you must handle it in the struts.xml configuration.

input result is returned by the Validation Interceptor when some validation error occurs, or when you are trying to set the wrong type of an Action's properties, for example when you try to set a int to a Date field.

When an Interceptor is returning a result instead of proceeding to the next Interceptor (or the Action if it is the last), the Action method called won't be executed, because it won't be reached.

Check out carefully your code and your request to see where it is failing and returning the input result.

P.S:

If with

I access the class before displaying the form because I want the dropdown option in the form to display the appropriate value as I instantiate it in action class.

you mean that you need to prepopulate fields before the execution of any method (or when input result is returned), you should use prepare() method for that, run by the Prepare Interceptor that runs before the Validation Interceptor. That way, your prepare() code will be executed even when validation will fail.

For more info, read How do we repopulate controls when validation fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!