Struts 2的基本配置

2021-05-27 17:42:37 字數 1066 閱讀 6170

--struts 2的基本配置第一步:整合到tomcat下

struts

org.apache.struts2.dispatcher.filterdispatcher

actionpackages

configproviders

providers.myconfigurationprovider

filterdispatcher類的初始化引數有如下3個:

(1)         config:該引數表示struts2框架自動載入的系列配置檔案。如果有多個配置檔案,中間用逗號(,)分隔。

(2)         actionpackages:該引數表示struts2框架要掃瞄的包,如在預設情況下,struts 2會掃瞄org.apache.struts2.static包,以獲得相應的靜態資源。struts2還會通過該屬性指定的包搜尋使用注釋定義的action類如果有多個包,中間用逗號(,)分隔。

(3)         configproviders:該引數表示自定義的configurationprovider類,使用者可以提供乙個或多個實現了configurationprovider介面的類,並將這些類名設定成configproviders屬性值。若果有多個configurationprovider類,中間用逗號(,)分隔。

在web.xml檔案中除了配置filter的主體部分,還需要配置該filter攔截的url。通常可以使用如下的**配置filterdispatcher要攔截的url。

struts2 

/* 

在配置完filterdispatcher過濾器後,struts 2 就已經成功整合到web應用中。

--struts 2的基本配置第二步:配置struts.xml 

<?xml version="1.0" encoding="utf-8"?>

/result.jsp

/error.jsp

struts-default.xml位於struts2-core-2.0.11.jar包中。

struts2-spring-plugin-2.0.11.2.jar中下的xml檔案:struts-plugin.xml

Struts2的基本配置

4 struts.xml檔案結構 struts.xml檔案時整個struts2框架的核心,下面提供了乙個最完整的struts.xml檔案,這個檔案沒有任何實際意義,僅僅是乙個struts.xml檔案的示範 20.引數值 21.22.23.24.25.26.27.28.29.引數值 30.31.32....

Struts2的基本配置

struts2 常見配置 1 struts2 配置檔案的載入順序 struts2 配置檔案 由核心控制器載入 strutsprepareandexecutefilter 預處理,執行過濾 init defaultproperties 1 org apache struts2 default.prop...

Struts2的基本配置

4 struts.xml檔案結構 struts.xml檔案時整個struts2框架的核心,下面提供了乙個最完整的struts.xml檔案,這個檔案沒有任何實際意義,僅僅是乙個struts.xml檔案的示範 view plaincopy to clipboardprint?01.02.03.06.07...