国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

Struts Convention Plugin 流程 (2.1.6+)

2019-11-14 22:12:55
字體:
供稿:網(wǎng)友
Struts Convention Plugin 流程 (2.1.6+)

首先添加lib:

<dependency>          <groupId>org.apache.struts</groupId>          <artifactId>struts2-config-browser-plugin</artifactId>          <version>2.3.20</version>      </dependency>      <dependency>          <groupId>org.apache.struts</groupId>          <artifactId>struts2-convention-plugin</artifactId>          <version>2.3.20</version>      </dependency>

訪問 http://localhost:8080/conv/config-browser/a.action 可以查看目前映射的所有路徑

插件會按以下順序執(zhí)行:

1.尋找以下包:struts, struts2, action ,actions

任何深度找到的以上包都自動(dòng)作為根目錄

2.然后在包內(nèi)尋找以下類:實(shí)現(xiàn)了com.opensymphony.xwork2.Action或者繼承了com.opensymphony.xwork2.ActionSupport,或類名以Action結(jié)尾

3.映射為url:

com.example.actions.MainAction -> /maincom.example.actions.PRoducts.Display -> /products/displaycom.example.struts.company.details.ShowCompanyDetailsAction -> /company/details/show-company-details(全部為小寫)

比如,image

會映射成,image image

可以跳過某些包:struts.convention.exclude.packages=org.apache.struts.*,org.apache.struts2.*,org.springframework.web.struts.*,org.springframework.web.struts2.*,org.hibernate.* (被跳過的包是無法再加入的,即使手動(dòng)添加)

自動(dòng)搜索的包名:struts.convention.package.locators=action,actions,struts,struts2

自動(dòng)搜索的包名開頭:struts.convention.package.locators.basePackage=

自動(dòng)搜索的類名結(jié)尾:struts.convention.action.suffix=Action

手動(dòng)指定具體包:struts.convention.action.packages=

4.默認(rèn),所有的Result都到這里去找:WEB-INF/content

如,image ,則可以通過 http://localhost:8080/conv/my-jsp.action 訪問到

可通過常量控制:struts.convention.result.path=/WEB-INF/content/

根據(jù)返回類型和返回字符串,要起不同的名字:

image

5.如果找不到這個(gè)頁面文件,就認(rèn)為這是個(gè)action,其他action可以在方法上添加@Action(“xx”),指明具體路徑,這也就是Result Type為chain

image 中,

public class MyJsp extends ActionSupport {    public String execute() {return "here";      }}
public class HimJsp extends ActionSupport {      @Action("my-jsp-here") //通過指定為具體路徑,實(shí)現(xiàn)chain,前提是沒有那個(gè)頁面文件      public String execute() {return "yes";      }}

最后會變成,

image

可以設(shè)置自動(dòng)重載:

<constant name="struts.devMode" value="true"/>

<constant name="struts.convention.classes.reload" value="true" />

struts.convention.action.alwaysMapExecute =false 禁止自動(dòng)調(diào)用execute()

struts.convention.action.disableScanning=true 禁用掃描

struts.convention.action.mapAllMatches =true 沒有@Action也自動(dòng)映射

struts.convention.action.name.lowercase=false 不要變成小寫

struts.convention.action.name.separator=_ 名稱分隔符

struts.convention.action.eagerLoading=true 不使用Spring的時(shí)候可以提高性能


上一篇:。JavaSE------初識Java

下一篇:DBUtils工具

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 昌江| 上栗县| 思南县| 黄平县| 霍林郭勒市| 湄潭县| 邹城市| 无极县| 惠州市| 额敏县| 黄冈市| 吕梁市| 新泰市| 苏州市| 木里| 濮阳县| 涟水县| 武隆县| 柘荣县| 卢龙县| 兴安县| 右玉县| 通许县| 平果县| 雅江县| 金川县| 开平市| 惠水县| 巴东县| 始兴县| 广昌县| 贵港市| 金寨县| 木里| 西华县| 井陉县| 沁源县| 濉溪县| 赣榆县| 抚宁县| 日喀则市|