Struts 2 中的范围及其标准 [英] Scopes in Struts 2 and standards for them

查看:29
本文介绍了Struts 2 中的范围及其标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Struts 2 应用程序中有多少个作用域?如果我们在那里使用 session 和 request 范围是否好?会话和请求的操作范围如何工作?

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?

推荐答案

Struts 2 正在运行一个容器,它有 bean 的作用域.关于 bean 范围的更多信息在 this 问题中.所有其他范围都是 servlet 范围.Struts 使用它自己的结构间接访问这些范围.例如,set 标签使用这些范围:

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:

可用范围如下:

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 

注意:

如果没有指定作用域,则默认为动作作用域.

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

这篇关于Struts 2 中的范围及其标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆