Struts Action 属性的解释

摘录自 Jarkata Struts Live 一书, 留备参考。

 

Action Attributes

 

Attribute Description

attribute The attribute specifies the name of the ActionForm that is mapped to a given
scope. If you do not specify an attribute, the name attribute becomes the value of
the attribute. Thus, if the attribute is not specified, the attribute defaults to the name
of the ActionForm.

 

className

The className attribute is used to specify custom config object. We will cover
these in Chapter 10 in more detail. For now, you can replace any config object with
a custom config object. The custom config object can have additional properties.


include

You can use the include attribute to specify a JSP that will handle this request. The
JSP is the only handler of this request. Using this should be the exception, not the
norm. This attribute is mutually exclusive with the forward attribute and the type
attribute, meaning that only one of the attributes can be set.

 

input

The input attribute is used to specify the input View for an action. The input attribute
usually specifies a JSP page that has an HTML form that submits to this action. If
there are any problems with form validation, then control of the application will forward
back to this input View. This attribute is optional, but if it’s not included, an
error occurs when Struts attempts to display validation errors.


name

The name attribute identifies the ActionForm that is related to this action. The html:
form tag uses this name to pre-populate the html form. The request processor uses
this form name to create and populate an ActionForm to pass to the execute()
method of the action handler.

path

The path attribute represents the incoming request path that this action maps to.

 

parameter

The parameter attribute is similar in concept to servlet init-parameters. Its use is
application-specific. You can think of it as a general-purpose init-parameter.

roles

The roles attribute is used to specify J2EE security roles that are allowed to access
this action. If this attribute is present, then only those roles specified in the commadelimited
list can use this action.


type

The type attribute specifies the action handler for this action. You must specify a
fully qualified class name. The type attribute is mutually exclusive with the include
and forward attribute.

scope

The scope specifies in which scope (request or session) the ActionForm will be
placed. The scope attribute defaults to session.


Unknown

The unknown attribute is used to specify a default action mapping to handle
unknown request paths. Obviously, you can only have one of these for each Struts
config file.

 

validate

The validate attribute is used when you want to validate the ActionForm. This is the
case when you are handling form submissions. By specifying validate equals=true,
you are causing the request processor to call the ActionForm.validate() method to
see if there are any field/form validation errors.
The execute() method of the action will not be called if form validation fails and validate
equals true. Instead, control of the application would return to the input View.
You typically set the validate attribute to false, if you want to pre-populate an HTML
form (e.g., an action that loads a form with form data from a database).

 

转载:http://space.itpub.net/5256/viewspace-119528

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值