`
younglibin
  • 浏览: 1194310 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

struts2中struts.xml全面配置文件模板

阅读更多

struts.xml文件是整个Struts 2框架的核心,下面提供了一个最完整的struts.xml文件,这个文件没有任何实际意义,仅仅是一个struts.xml文件示范。如果对DTD熟悉的话就不用看该文件了,在配置时可以参考该文件:

<?xml version="1.0" encoding="GBK"?>
<!-- 下面指定Struts 2.1配置文件的DTD信息 -->
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
"http://struts.apache.org/dtds/struts-2.1.dtd">
<!-- struts是Struts 2配置文件的根元素 -->
<struts>
              <!-- 下面元素可以出现零次,也可以出现无数次 -->
              <constant name="" value="" />
              <!-- 下面元素可以出现零次,也可以出现无数次 -->
              <bean type="" name="" class="" scope="" static="" optional="" />
              <!-- 下面元素可以出现零次,也可以出现无数次 -->
              <include file="" />
       <!-- package元素是Struts配置文件的核心,该元素可以出现零次,或者无数次 -->
      <package name="必填的包名" extends="" namespace="" abstract=""
              externalReferenceResolver>
           <!-- 该元素可以出现,也可以不出现,最多出现一次 -->
          <result-types>
                <!-- 该元素必须出现,可以出现无数次-->
                <result-type name="" class="" default="true|false">
                    <!-- 下面元素可以出现零次,也可以无数次 -->
                    <param name="参数名">参数值</param>*
                </result-type>
          </result-types>
        <!-- 该元素可以出现,也可以不出现,最多出现一次 -->
        <interceptors>
   <!-- 该元素的interceptor元素和interceptor-stack至少出现其中之一,
   也可以二者都出现 -->
   <!-- 下面元素可以出现零次,也可以无数次 -->
            <interceptor name="" class="">
    <!-- 下面元素可以出现零次,也可以无数次 -->
    <param name="参数名">参数值</param>*
          </interceptor>
   <!-- 下面元素可以出现零次,也可以无数次 -->
          <interceptor-stack name="">
    <!-- 该元素必须出现,可以出现无数次-->
                    <interceptor-ref name="">
    <!-- 下面元素可以出现零次,也可以无数次 -->
                          <param name="参数名">参数值</param>*
                   </interceptor-ref>
           </interceptor-stack>
  </interceptors>
  <!-- 下面元素可以出现零次,也可以无数次 -->
  <default-interceptor-ref name="">
   <!-- 下面元素可以出现零次,也可以无数次 -->
           <param name="参数名">参数值</param>
  </default-interceptor-ref>
  <!-- 下面元素可以出现零次,也可以无数次 -->
  <default-action-ref name="">
   <!-- 下面元素可以出现零次,也可以无数次 -->
   <param name="参数名">参数值</param>*
  </default-action-ref>
   <!-- 下面元素可以出现零次,也可以无数次 -->
   <global-results>
    <!-- 该元素必须出现,可以出现无数次-->
    <result name="" type="">
     <!-- 该字符串内容可以出现零次或多次 -->
     映射资源
     <!-- 下面元素可以出现零次,也可以无数次 -->
     <param name="参数名">参数值</param>*
    </result>
   </global-results>
  <!-- 下面元素可以出现零次,也可以无数次 -->
  <global-exception-mappings>
   <!-- 该元素必须出现,可以出现无数次-->
   <exception-mapping name="" exception="" result="">
    异常处理资源
    <!-- 下面元素可以出现零次,也可以无数次 -->
    <param name="参数名">参数值</param>*
   </exception-mapping>
  </global-exception-mappings>
  <action name="" class="" method="" converter="">
   <!-- 下面元素可以出现零次,也可以无数次 -->
   <param name="参数名">参数值</param>*
   <!-- 下面元素可以出现零次,也可以无数次 -->
   <result name="" type="">
   映射资源
   <!-- 下面元素可以出现零次,也可以无数次 -->
   <param name="参数名">参数值</param>*
   </result>
   <!-- 下面元素可以出现零次,也可以无数次 -->
   <interceptor-ref name="">
   <!-- 下面元素可以出现零次,也可以无数次 -->
   <param name="参数名">参数值</param>*
   </interceptor-ref>
   <!-- 下面元素可以出现零次,也可以无数次 -->
   <exception-mapping name="" exception="" result="">
   异常处理资源
   <!-- 下面元素可以出现零次,也可以无数次 -->
   <param name="参数名">参数值</param>*
   </exception-mapping>
  </action>
 </package>*
 <!-- unknown-handler-stack元素可出现零次或1次 -->
 <unknown-handler-stack>
  <!-- unknown-handler-ref元素可出现零次或多次 -->
  <unknown-handler-ref name=" ">...</unknown-handler-ref>*
 </unknown-handler-stack>?
</struts>

分享到:
评论

相关推荐

    struts2的struts.xml文件模板

    一个struts2的模板,可以根据模板里的注释快速填写struts.xml中的内容。请注意,一定要将此文件放置于工程的src目录下。

    Struts2技术手册-Struts2精华教程-电子书

    本书内容非常全面,涵盖了众多书籍所有知识要点,并结合作者自己经验总结而编写,内容相当丰富,是查找技术的好帮手及学习Struts2的不二选择 众所周知,一般书籍为了销售需要,往往很少的知识点,却需要添加大量的...

    Struts2属性文件详解

    该属性指定加载Struts 2配置文件的配置文件管理器.该属性的默认值是org.apache.Struts2.config.DefaultConfiguration, 这是Struts 2默认的配置文件管理器.如果需要实现自己的配置管理器,开发者则可以实现一个实现...

    Struts2入门教程(全新完整版)

    3.初识struts2配置文件 4 (1).web.xml文件 4 (2).struts.xml文件 4 (3).struts.properties(参default.properties) 4 (4)struts-default.xml 4 (5)其它配置文件 4 4.让MyEclipse提示xml信息 4 5.如何...

    Struts2\constant应用

    该属性指定Struts 2框架默认加载的配置文件,如果需要指定默认加载多个配置文件,则多个配置文件的文件名之间以英文逗号(,)隔开。 该属性的默认值为struts-default.xml,struts-plugin.xml,struts.xml,看到该属性...

    Struts in Action中文版

    2. 深入 STRUTS架构..................................................................................37 2.1. 随便谈谈......................................................................................

    struts in Action

    2. 深入STRUTS 架构..................................................................................37 2.1. 随便谈谈.......................................................................................

    Struts2整合SiteMesh技巧

    如果需要使用Freemark模板文件作为装饰器文件,需要在web.xml文件中添加如下配置: xml 代码 &lt;filter&gt; &lt;filter-name&gt;struts-cleanup&lt;/filter-name&gt; &lt;filter-class&gt;org.apache.struts2.dispatcher....

    Struts2 国际化字符串 拦截器

    例3 classes/struts.xml中VMHelloWorld Action的配置 新建HelloWorld.vm,内容如下所示: &lt;title&gt;Velocity ; charset=UTF-8"&gt; &lt;h2&gt;Message rendered in Velocity: $message struts-dojo-tags

    xdoclet1 xdoclet1 spring3.0.5、struts1.3、struts2.1、 servlet

    XDoclet可以通过你在java源代码中的一些特殊的注释信息,自动为你生成配置文件、源代码等等,例如web、ejb的部署描述文件、config.xml配置文件、javascript校验等。本资源我在学习xdoclet过程中,总结完成的xoclet...

    SSH框架搭建全套jar包+全套c3p0+ojdbc14.jar+各种xml(模板)

    全部都经过了测试,共94个jar包(所有包全部兼容) 包括:SSH全套jar包c3p0+ojdbc14.jar+.hbm.xml(模板)+applicationContext.xml+struts.xml+web.xml======

    struts2讲义_吴峻申

    3.1 使用web.xml配置Struts2实现Web项目Struts2应用 37 3.2 使用配置文件struts.xml实现页面导航定义 38 3.3 使用Action类控制导航业务数据 40 3.4 使用ActionSupport进行校验 42 第4章 另一Struts2核心技术:拦截器...

    struts2.0.jar

    Struts 2.0框架中出现的许多特性旨在让Struts更容易使用: · 改进的设计: 与Struts 1相比...· 易于定制的控制器: Struts 1允许请求处理程序可按照模块来定制,在Struts 2中,需要的话,可以按照动作来定制请求处理。

    Struts2 in action中文版

    6.7.2 Struts 2中常用的表达式语言特性 131 6.7.3 表达式语言的高级特性 135 6.8 小结 137 第7章 UI组件标签 139 7.1 为什么需要UI组件标签 139 7.2 标签、模板和主题 144 7.2.1 标签 146 7.2.2 模板 146 7.2.3 ...

    ssh2(struts2+spring2.5+hibernate3.3)自动生成模版

    4个xml文件(applicationContext-dao.xml(dao注入配置),applicationContext-service.xml(service注入配置),action-servlet.xml(action注入配置),struts-{自定义的存放包名}.xml(struts2的action配置文件)) ...

    配置文件模版.zip

    这里面全是搭建框架所需要的各种xml文件。有struts,hibernate,spring,mybatis等xml的配置文件模板

    webx3框架指南PDF教程附学习Demo

    2.2.1. XML Schema中的秘密 ................................................................. 16 2.2.2. 扩展点,Configuration Point ....................................................... 17 2.2.3. ...

    Spring-Reference_zh_CN(Spring中文参考手册)

    2.2.1. 更简单的XML配置 2.2.2. 新的bean作用域 2.2.3. 可扩展的XML编写 2.3. 面向切面编程(AOP) 2.3.1. 更加简单的AOP XML配置 2.3.2. 对@AspectJ 切面的支持 2.4. 中间层 2.4.1. 在XML里更为简单的声明性事务配置 ...

    Spring中文帮助文档

    2.2.2. 更简单的XML配置 2.2.3. 可扩展的XML编写 2.2.4. Annotation(注解)驱动配置 2.2.5. 在classpath中自动搜索组件 2.3. 面向切面编程(AOP) 2.3.1. 更加简单的AOP XML配置 2.3.2. 对@AspectJ 切面的支持 ...

Global site tag (gtag.js) - Google Analytics