Avoid Return “input” Automatically in Struts

后端 未结 1 669
抹茶落季
抹茶落季 2020-12-20 04:21

There is no problem when the action configuration in struts.xml is like this:


          


        
相关标签:
1条回答
  • 2020-12-20 04:50

    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

    0 讨论(0)
提交回复
热议问题