摘录自 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
分享到:
相关推荐
Struts2 框架中,Action 组件可以通过多种方式接收参数,这些方式包括使用 Action 的属性、使用 DomainModel 和使用 ModelDriven。下面将详细介绍这些方法: 使用 Action 的属性接收参数 在 Struts2 中,可以使用 ...
该属性指定需要Struts 2处理的请求后缀,该属性的默认值是action,即所有匹配*.action的请求都由Struts 2处理.如果用户需要指定多个请求后缀,则多个后缀之间以英文逗号(,)隔开. struts.serve.static 该属性设置是否...
首先,Struts的ActionServlet接收到一个请求,然后根据struts-config.xml的配置定位到相应的mapping (映射);接下来如果form的范围是request或者在定义的范围中找不到这个form,创建一个新的form实例;取得form...
NULL 博文链接:https://cdxs2.iteye.com/blog/1925245
从jsp页面提交form表单后,在struts.xml中寻找匹配的action。在action中处理完业务后返回,在struts.xml中的result属性中转向到另外一个action。
struts1.x_action属性详解
NULL 博文链接:https://huangminwen.iteye.com/blog/1828698
第1章 Struts 2:现代Web框架 2 1.1 Web应用程序:快速学习 2 1.1.1 构建Web应用程序 2 1.1.2 基础技术简介 3 1.1.3 深入研究 6 1.2 Web应用程序框架 7 1.2.1 什么是框架 7 1.2.2 为什么使用框架 8 1.3 Struts 2框架...
1 在Action实现类方面的对比:Struts 1要求Action类继承一个抽象基类;Struts 1的一个具体问题是使用抽象类编程而不是接口。Struts 2 Action类可以实现一...Struts 2 Action可以通过初始化、设置属性、调用方法来测试。
jQuery EasyUI与Struts2 的整合—属性驱动篇 如果你是用模型驱动,或者是直接把属性写在action里面,你不会碰到我遇到的那么多问题。 但是你用模型驱动好吗,如果一个页面需要处理多个对象的时候怎么办。 如果你...
Struts ActionServlet控制器对象 8 Struts Action Classes 8 Struts Action Mapping 9 使用ActionForward导航 10 Struts ActionForm Bean捕获表单数据 11 Struts的其他组件 12 Validation Framework for ...
Struts ActionServlet控制器对象 8 Struts Action Classes 8 Struts Action Mapping 9 使用ActionForward导航 10 Struts ActionForm Bean捕获表单数据 11 Struts的其他组件 12 Validation Framework for Struts 12 ...
详细介绍Struts2 如何使Action取得属性范围 通配符 国际化等内容,并使用事例说明
其中包括: Struts In Action中文版.pdf Struts 配置骨架.xml Struts 配置元素.doc web_xml中ActionServlet中的属性.doc
下面将对Struts.properties配置文件中的重要参数进行详细解释。 1. struts.action.extension:这是Struts2用来确定是否将请求作为Struts操作的URL扩展名。例如,登录操作的URL可以是login.do,struts.action....
使用struts2的标签,在页面上用列表的方式列出action里集合中所有元素的所有属性值
* 可测性:Struts1.2 Action 的一个主要问题是 execute 方法暴露了 Servlet API,而 Struts2.0 Action 可以通过初始化、设置属性、调用方法来测试,“依赖注入”也使得测试更容易。 三、项目中使用 SSH 的原因 ...
Struts ActionServlet控制器对象 8 Struts Action Classes 8 Struts Action Mapping 9 使用ActionForward导航 10 Struts ActionForm Bean捕获表单数据 11 Struts的其他组件 12 Validation Framework for Struts 12 ...
重写validate方法校验将会产生两种错误信息:Field级别错误信息,Action级别的错误信息 Field级别错误信息就是将错误信息添加到fieldErrors,也就是将错误信息添加到addFieldError方法中。 Action级别的错误信息...
Struts2+Spring+Hibernate 中的Action单元测试环境搭建 在软件开发中,单元测试是一种非常重要的测试方法,可以帮助我们确保代码的可靠性和稳定性。在 Struts2+Spring+Hibernate 框架中,对 Action 的单元测试环境...