difference in the property value fetched in validate and model method in Struts2

元气小坏坏 提交于 2019-12-06 14:35:29

The values are get/set by the order of the interceptor invocations. As long as the action is on the valuestack, after prepare the params interceptor is called getModel() to get the object whose property should be set.

The modelDriven interceptor also retrieves model from the valuestack. Any subsequent searches for the model properties via expression results to call getModel() while the property isn't set yet. The params interceptor sets property finally, then validation interceptor is invoked, which is also retrieves getModel() to get the property values that should be already set.

The console will look like above. It's a normal behavior of the interceptors until the action is executed. In the first case you didn't send values with the request, therefore the console prints what has been after prepare. In the second the value is sent and property has been changed, so the console reflected it. Values are coming with the http request, so it's the same "location" in the scope of request.

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