Scopes in Struts 2 and standards for them

ⅰ亾dé卋堺 提交于 2019-12-08 04:48:16

问题


How many scopes are there in Struts 2 applications? And is it good if we use session and request scope there? How action scope work for session and request both?


回答1:


Struts 2 is running a container, it has scopes for beans. More about bean scopes is in this question. All other scopes are servlet scopes. Struts uses indirect access to these scopes using it's own structures. For example a set tag uses these scopes:

The scopes available are as follows :

application - the value will be set in application scope according to servlet spec. using the name as its key
session - the value will be set in session scope according to servlet spec. using the name as key
request - the value will be set in request scope according to servlet spec. using the name as key
page - the value will be set in page scope according to servlet sepc. using the name as key
action - the value will be set in the request scope and Struts' action context using the name as key 

NOTE:

If no scope is specified, it will default to action scope.



来源:https://stackoverflow.com/questions/27666146/scopes-in-struts-2-and-standards-for-them

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