`
mmdev
  • 浏览: 12929157 次
  • 性别: Icon_minigender_1
  • 来自: 大连
文章分类
社区版块
存档分类
最新评论

Struts-config.xml 详细说明

 
阅读更多

<?xml version = "1.0" encoding = "ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-Apache SoftWare Foundation//DTD Struts Configuration 1.1/EN"
"http://jakarta.apache.org/struts/dtd/struts-config_1_1.dtd">

<!--
This is the Struts configuration file for the "Hello!" sample application
-->

<struts-config>
<!--==========================Form Bean Definitions=======================-->
<form-beans>
<form-bean name = "HelloForm" // 页面中表单对应的Bean存储表单数据, 验证
type = "hello.HelloForm" // FormBean 对应的包名.类名
/>
</form-beans>
<!--========================Global-forwards=======================-->

<!--
<global-forwards>元素用来声明全局的转发关系. 由0个或多个<forward>元素组成. <forward> 元素用于将一个逻辑名映射到特定的URL. 通过这种方式, Action类或者JSP文件无需指定实际的URL, 只要指定逻辑名就能实现请求转发或者重定向.
-->

<global-forwards>
<forward name = "forward1" // 转发路径的逻辑名, 此项必须有
path = "/Action1.do" // 指向转发或重定向的URI. 此项是必需的, 必须以"/"开头.
/>
<forward name = "forward2" path="/Action2.do"/>
<forward name = "forward3" path="/jsp3.jsp"/>
</global-forwards>

<!--
如果jsp1.jsp把请求转发给Action1, 可以使用以下代码:
<html:link forward = "forward1">
或:
<logic:forward name = "forward1">
如果Action1的execute()方法把请求转发给jsp1.jsp
return (mapping.findForward("forward1"));
-->
<!--=========================Action Mapping Definitions=======================-->
<action-mapping>
<action path = "/HelloWorld" // 请求访问Action的路径, 必须以"/"开头
type = "hello.HelloAction" // Action的完整类名
name= "HelloForm" // 要传给Action 的ActionForm Bean
scope = "request" // ActionForm Bean 的存放范围
validate= "true" // 是否执行表单验证
input = "/hello.jsp" // 当表单验证失败时转发的路径, 必须以"/"开头
>
<forward name = "SayHello" // 键值用于标识此forward
path = "/hello.jsp" // 请求转发的路径, 必须以"/"开头
/>
</action-mapping>
<!--
<action>元素配置了HelloAction组件, 对应的类为hello.HelloAction, 请求访问路径为 "HelloWorld", 当Action 类被调用时, Struts 框架应该把已经包含表单数据的HelloForm Bean传给它. HelloForm Bean 存放在request范围内, 并且在调用Action 类之前应该进行表单验证, 如果表单验证失败, 请求将被转发到接收用户输入的网页 hello.jsp, 让用户纠正错误.
-->
<!--=================Message Resources Definitions=================-->
<message-resource
parameter = "hello.application" // 指定使用的消息资源文件
// hello.application 表明
// 消息资源文件名为"application.properties"
// 存放路径为
// WEB-INF/classes/hello/application.properties
/>
</struts-config>

这些配置信息在系统启动时, 被存入内存中, 供Struts运行期间使用. 在内存中每个<action>元素都对应一个org.apache.struts.action.ActionMapping 类的实例 .


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics