1.<form-bean>
Contains form bean
definitions. The Form beans create ActionForm instances at runtime. The
details of each form bean are provided in the <form-bean>
element. The <form-property>
elements within the form bean contain the property names and the property types of the form bean.
Attributes of <form-bean> are:
-
name
:
Must have a unique bean name. This name is used as reference in the
action mappings. Often, this is also the name of the request or the
session attribute under which the form is stored.
-
type
: The value is a fully-qualified classname of the ActionForm class used with the form bean.
Attributes of <form-property> are:
-
name
: Contains the name of a property of the form bean.
-
type
: Contains the property type such as String, String[], etc.
Example Entry
<form-bean name="EventCVForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="cvName" type="java.lang.String"/>
<form-property name="severity" type="java.lang.String[]"/>
......
</form-bean>
2.action-mapping
Contains the action definitions. Each action mapping is defined in an <action> element. The <forward>
definition within <action>
,
maps
the result of the action to the jsp page invoked. This is a 'local'
forward and is optional. That is, for the particular request object, if
there is no forward defined in the global forwards, it is specified in
the <action-mapping> element.
Attributes of <action-mappings> are:
-
path
: Contains the name of the request received
-
type
: Contains the name of the action class invoked
-
scope
: Specifies the scope in which the Controller (ActionServlet) must look for the bean
Attributes of (local) <forward> within <action-mappings> are the same as that of the global <forward>.
Example Entry
<action-mappings>
<action path="/NetworkEvent"
type="com.adventnet.nms.webclient.fault.event.EventViewAction"
scope="request">
<forward name="eventView" path="NetworkEventPage" contextRelative="true"/>
</action>
</action-mappings>
In
the above entry, when a request matching the specified path
(NetworkEvent) is received, an instance of the ActionClass is created.
The controller looks for the bean in the specified scope (request)
creating and saving a bean of the specified class, if needed. The
ActionForward object is returned and the reference to the object is
acquired using mapping.findforward .. The layout for the page
displaying network events is defined in the corresponding tiles
definition file, where the page components and the corresponding JSPs
are specified.
更多Struts1中的struts-config.xml属性可以连接:
http://www.webnms.com/webnms/help/developer_guide/web_client/web_struts_config.html
分享到:
相关推荐
为了正确地配置 Struts 的 `ActionServlet`,`web.xml` 文件中的 `<servlet>` 元素必须出现在 `<servlet-mapping>` 元素之前,而 `<servlet-mapping>` 又必须出现在 `<taglib>` 元素之前。这种顺序是非常重要的,...
这是Struts1.x的核心配置文件,用于定义Action、Form Bean、Forward等。例如: ```xml <struts-config> <form-beans> <!-- 定义Form Bean --> </form-beans> <global-exceptions> <!-- 全局异常处理 --> </...
1. **ActionServlet**:`<servlet>` 和 `<servlet-mapping>` 配置Struts 的核心控制器,即 ActionServlet。`<init-param>` 用于指定配置文件 `struts-config.xml` 的位置,例如: ```xml <servlet> <servlet-name...
- **struts-config.xml**:这是Struts1的核心配置文件,包含了所有Action、Form Bean、Forward、Plug-in等配置信息。例如: ```xml <struts-config> <form-beans> <!-- Form Bean配置 --> </form-beans> ...
<load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>ActionServlet</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> ``` - `<init-param>`:通过`...
next3: struts控制器根据name="HelloForm"找<form-beans>中对应的<form-bean> next4: <form-bean>调用指定的type类 关联: 如果validate是"true"那么调用type类的validate(); next5: struts控制器在HelloForm bean...
- `<action-mappings>` 标签定义了 Action 的映射关系,包括 Action 类型、Form Bean 名称、输入页面、作用域和验证标志。 - `<forward>` 标签定义了 Action 执行后的跳转路径。 #### 总结 通过上述分析,我们可以...
<form-bean name="uploadForm" type="org.apache.struts.action.DynaActionForm"> <form-property name="type" type="java.lang.String[]"/> <form-property name="name" type="java.lang.String[]"/> <form-...
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts/struts.xml</param-value> </init-param> <init-param...
如果是从数据库获取内容,并在kindEditor里选中,在action中定义content属性,setContent(bean.getContent());这种方式 中文乱码不是问题,一般struts2+spring开发项目的时候,使用spring的filter就可以搞定 ...
例如,在 `struts-config_1.xml` 中,你可以定义与模块1相关的所有 Action 和 Form Bean。 ```xml <struts-config> <form-beans> <!-- 定义表单 bean --> </form-beans> <action-mappings> <!-- 定义 Action ...
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>application</param-name> <param-value>ApplicationResources</param-value> </init-param> <init-...
3. 配置`struts-config.xml`:这是Struts的核心配置文件,用于定义Action、Form Bean、Action Mapping等。一个简单的配置示例如下: ```xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC...
在Struts的`struts-config.xml`中,配置Action和Form Bean,以及ActionForward,来定义请求的路由。同时,Spring可以注入Service层的Bean到Action中,实现业务逻辑处理。在JSP页面中,使用Struts标签库或者EL表达式...
struts-config.xml是Struts框架的核心配置文件,它定义了Action类、Form Bean、Action Mapping以及数据源等关键组件。例如,你可以在这里声明一个Action,指定它的类路径和处理请求的URL,同时配置表单Bean,以处理...
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <init-param...
1. 创建一个名为`HelloForm`的Java类,继承自`org.apache.struts.action.ActionForm`,并添加一个属性(如`message`)。 ```java public class HelloForm extends ActionForm { private String message; // ...
Struts 1.XX 是一个基于MVC(Model-View-Controller)设计模式的Java Web框架,它在早期Web开发中被广泛使用。`<html:file>`是Struts提供的一个标签,主要用于处理用户在HTML表单中上传文件的功能。在Struts 1中,这...