struts2 spring integrates fieldError problems
- 2020-05-10 18:37:46
- OfStack
Question:
Using the validation framework, after the validation failure of the jsp page for 1 time, it cannot jump to except page regardless of whether the re-entry is correct or not.
The reason:
When spring creates action objects, the default is the singleton mode (singleton). By singleton, spring generates only one object for each IOC container. However, in my verification, I did not request the submission for a single time, but used an action object, so all the error messages were saved into map (fieldError information) and not cleared.
Solutions:
So in order to clear the error message from map for each request, I need to recreate an object for each request that USES action. The bean corresponding to action should be configured with the scope="prototype" in the applicationContext-*.xml file. This will accomplish the purpose. The problem is solved.