| 网站首页 | JAVA文章 | AppServers | Web开发 | 应用开发 | 资源下载 | 论坛
    想学好编程,学好外语很重要  [enadd  2006年12月25日]        
设为首页 加入收藏 联系站长
您现在的位置: 编程笔记网 >> JAVA文章 >> STRUTS >> 文章正文
Struts-config.xml配置文件讲解          【字体:
Struts-config.xml配置文件讲解
作者:-    文章来源:-    点击数:    更新时间:2006-4-13

  Struts的核心是struts-config.xml配置文件,在这个文件里描述了所有的Struts组件。在这里包括配置主要的组件及次要的组件,下面是struts-config.xml包含主要元素的内容:

一、    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/dtds/struts-config_1_1.dtd">
<struts-config>
  
   <data-sources>
       <data-source>
       </data-source>
   </data-sources>

   <form-beans>
       <form-bean / >
   </form-beans>

   <global-forwards>
       <forward / >
   </global-forwards>

   <action-mappings>
       <action / >
   </action-mappings>

   <controller / >

   <message-resources / >

   <plug-in />

</struts-config>
注意:以上各元素的顺序是非常重要的,你的struts-config.xml配置文件必须按照这个顺序进行配置,否则在你的容器启动的时候就会出错。

二、    struts-config.xml的子元素:
1.<icon / >子元素
   它包含<small-icon / >及<large-icon / >,它的作用是图形化其父元素,<small-icon/>的内容是一个16x16的图像文件,而<large-icon/>的内容是一个32x32的图像文件。如下例子:
   <icon>
<small-icon>
              /images/smalllogo.gif
</small-icon>
<large-icon>
    /images/largelogo.gif
</large-icon>
</icon>
2.<display-name / >子元素
   它提供对父元素的短文字(short textual)描述信息,如下:
   <display-name>
           short textual discription of its parent element
   </display-name>
3.<description / >子元素
   它提供对父元素的完全(full-length textual)的描述信息,如下:
<description>
full-length textual discription of its parent element
</description>
4.<set-property / >子元素
       它用来设置它的父元素中设定的JavaBean的属性值,它一般用在指定的GenericDataSource 属性,扩展的ActionMappings以及扩展的 global forwards。如下:
       <set-property
           property="name of bean property"      
value="value of bean property" />
         例如:
         <set-property property="driverClass" value="org.gjt.mm.sql/Index.html'>mysql.Driver" />
        <set-property property="user" value="admin"/>
        <set-property property="maxCount" value="4"/>
<set-property property="minCount" value="2"/>
<set-property property="password" value=""/>
<set-property property="url" value="jdbc:sql/Index.html'>mysql://localhost:3306/struts"/>

[1] [2] [3] [4] [5] 下一页  

文章录入:enadd    责任编辑:enadd 
  • 上一篇文章: 没有了

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    没有相关文章
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 管理登录 |