struts.xml配置詳解
struts.xml是我們在開發中利用率最高的檔案,也是Struts2中最重要的配置檔案。
一下分別介紹一下幾個struts.xml中常用到的標籤
1、<include>
利用include標籤,可以將一個struts.xml配置檔案分割成多個配置檔案,然後在struts.xml中使用<include>標籤引入其他配置檔案。
比如一個網上購物程式,可以把使用者配置、商品配置、訂單配置分別放在3個配置檔案user.xml、goods.xml和order.xml中,然後在struts.xml中將這3個配置檔案引入:
struts.xml:
1 2 3 4 5 6 7 8 9 10 |
<? xml version="1.0"
encoding="UTF-8"?>
<! DOCTYPE struts
PUBLIC
"-//Apache
Software Foundation//DTD Struts Configuration 2.0//EN"
< struts >
< include file="user.xml"/>
< include file="goods.xml"/>
< include file="order.xml"/>
</ struts >
|
user.xml:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<? xml version="1.0"
encoding="UTF-8"?>
<! DOCTYPE struts
PUBLIC
"-//Apache
Software Foundation//DTD Struts Configuration 2.0//EN"
< struts >
< package name="wwfy"
extends="struts-default">
< action name="login"
class="wwfy.user.LoginAction">
<!--省略Action其他配置-->
</ action >
< action name="logout"
class="wwfy.user.LogoutAction">
<!--省略Action其他配置-->
</ action >
</ package >
|