struts2 convention外掛程式配置說明

2021-05-23 12:59:49 字數 1401 閱讀 2914

struts2開發了convention外掛程式來支援零配置檔案的功能,以下是struts2 convention中的配置屬性說明:

1、常量說明

struts.convention.result.path="/web-inf/content/": 結果頁面存放的根路徑,必須以 "/" 開頭。

struts.convention.action.suffix="action": action名字的獲取 

struts.convention.action.name.lowercase="true": 是否將action類轉換成小寫

struts.convention.action.name.separator="-": 

struts.convention.action.disablescanning="false": 是否不掃瞄類。

struts.convention.default.parent.package="convention-default":設定預設的父包。

struts.convention.package.locators="action,actions,struts,struts2": 確定搜尋包的路徑。

struts.convention.package.locators.disable="false": 

struts.convention.package.locators.basepackage="": 搜尋的跟路徑

struts.convention.exclude.packages=

"org.apache.struts.*,org.apache.struts2.*,org.springframework.web.struts.*,

org.springframework.web.struts2.*,org.hibernate.*": 排除哪些包不搜尋。

struts.convention.relative.result.types="dispatcher,velocity,freemarker": 預設返回的結果型別搜尋。

struts.convention.result.flatlayout="true": 是否結果型別作為檔名的一部分。假如結果返回值為error,

2、註解

1)@resultpath:設定結果頁面位於**,用於覆蓋預設值。預設值由struts.convention.result.path常量設定。

@resultpath("/web-inf/pages")

2)@namespace:設定action的url路徑,用於覆蓋預設值

@namespace("/")

3)@action 用來標識struts2 action方法

@action(value="",results=)

其中,value為標識該action的名稱,result為action返回後,結果的名稱和定向路徑。

Struts 2 Struts2 詳細配置

全域性配置 配置在packe 中,所有 action 的上面。頁面 頁面 區域性結果優先順序高於全域性。異常資訊配置 404異常 500異常 web.xml 配置 404 error.jsp 500 error.jsp 包 package 配置 所有的action 配置,都必須在包中。jsp頁面路徑...

Struts2字尾 深入Struts2

一 將action字尾變成html字尾 xmlversion 1.0 encoding utf 8 doctype struts public apache software foundation dtd struts configuration 2.1 en struts include file...

Struts2入門(一)Struts2簡介

本章簡要介紹一下struts2框架 1.概念 我們知道,springmvc框架是為了整合servlet設計的控制層框架,那麼還有其他的框架也實現了這個功能,那麼就是struts2。struts2是乙個基於mvc設計模式的web應用框架,它本質上相當於乙個servlet,在mvc設計模式中,strut...