Struts 2 採用分層配置機制:
struts2-core-x.jar 中)src/ 根目錄,編譯後進入 classes/)項目啟動時,struts.properties 中的屬性將覆蓋同名默認值。
默認情況下,Action 請求 URL 以 .action 結尾(如 /Hello.action)。若需改為 .do:
在 default.properties 中定義:
struts.action.extension=action
在 src/struts.properties 中添加:
struts.action.extension=do
重新部署 Web 應用後,原請求 https://localhost:8080/Chapter01-FirstStruts2/Hello.action 失效,新請求 https://localhost:8080/Chapter01-FirstStruts2/Hello.do 正常響應。
struts2-core.jar)struts.properties 中覆蓋確需修改的屬性,保持配置最小化struts.devMode(開發模式)、struts.i18n.encoding(國際化編碼)、struts.action.extension(URL 後綴)