Struts框架中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://struts.apache.org/dtds/struts-config_1.2.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 类的实例

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值