天天看點

【Struts架構】第一節Action-子產品包含和defaultAction

1.子產品包含:

struts.xml:

裡面可以這麼寫

<include file="login.xml"></include>

說明在struts.xml包含了一個login.xml檔案

login.xml:

及相當于在struts.xml檔案中添加了login.xml的内容

這個東西應用的場景:

多人開發的情況,每個人在各自不同的機器上開發,可以寫xml檔案,最後整合的時候将所有子產品的xml檔案組合在一個struts檔案中(将公用配置設定在struts.xml中)

2.defaultaction:

如果找不到對應的action或者敲action的時候,是通路不到action的,這個時候會報錯。是以我們要設定預設的action給使用者一個友好界面,防止這種情況的發生。

struts中這樣配置:

當輸入action為空或者錯誤名時,就會跳轉到default.jsp這個友好提示界面

如:

http://localhost:8080/struct2_0100_introduction/

或者:

http://localhost:8080/struct2_0100_introduction/faasa(不存在的action)

跳轉到default.jsp:

轉載請注明出處:http://blog.csdn.net/acmman/article/details/44463511