webx roadmap

SpringExt

自定義Spring Schema的例子

基於Spring可擴展Schema提供自定義配置支持css

使用SpringExt擴展Webx的示例html

擴展點和捐獻

一個namespace下能夠聲明多個element。java

擴展點:將namespace和接口關聯起來。
捐獻:將element和實現關聯起來。git

webx archetype

tutorial1


tutorial11.PNG
mvn archetype:generate -DgroupId=com.alibaba.webx -DartifactId=tutorial1 -Dversion=1.0-SNAPSHOT -Dpackage=com.alibaba.webx.tutorial1 -DarchetypeArtifactId=archetype-webx-quickstart -DarchetypeGroupId=com.alibaba.citrus.sample -DarchetypeVersion=1.8 -DinteractiveMode=false

login-webx3-tutorial

該示例是tutorial1示例中的「5. Form Validation」部分的內容。github


login-webx3-tutorial.PNG
mvn archetype:generate -DgroupId=com.alibaba.webx -DartifactId=login-webx3-tutorial -Dversion=1.0-SNAPSHOT -Dpackage=com.alibaba.webx.tutorial -DarchetypeArtifactId=archetype-webx-quickstart -DarchetypeGroupId=com.alibaba.citrus.sample -DinteractiveMode=false

petstore

git clone https://github.com/webx/citrus-sample.git cd citrus-sample/petstore mvn clean install cd web mvn jetty:run-war

第五章

web應用根目錄
就是指的是web項目的根目錄。
/WEB-INF/web.xml
上述的/不是相對於操做系統而言,而是針對web項目而言。web

charset

每一端都有input chaset 和output charset。這就比如socket通訊,每一端都有輸入流和輸出流。spring

如何將url轉爲target

AnalyzeURLValve:取得target,action,actionEvent。
(1)經過request.getServletPath()+request.getPathInfo()獲取請求的pathInfo,並經過MappingRuleService將pathInfo轉爲target。
(2)取得請求中的action參數。經過MappingRuleService獲得最後的action。
(3)獲得請求中的actionEvent。ruby

對開發者的要求:
(1)配置MappingRuleService的映射規則。即<services:mapping-rules>bash

如何將target映射到action

PerformActionValve:根據action參數找到具體的action類,而後執行其execute()方法。
ModuleLoaderService.getModule(action).execute()
Module就是一個含execute()方法的接口。架構

<direct-module-rule>元素表示直接映射module,這是最簡單的模塊映射規則。
它映射Module的原理是:將URL路徑"/"替換成".",除去文件名後綴,將最後一個單詞首字母改爲大寫,以符合模塊命名的規則。
好比http://abc.com/helloapp/path/hello.htm

webx根據你訪問的URL target 「path/hello.htm」,定位到 Module 「path.hello.class」

<services:module-loader>
        <ml-factories:class-modules> <search-packages type="$1" packages="com.alibaba.sample.petstore.web.common.module.*" /> </ml-factories:class-modules> </services:module-loader>

webx相關blog

petstore-web的src目錄以下:

src
└─main
    ├─java
    │  └─com
    │      └─alibaba
    │          └─sample
    │              └─petstore
    │                  └─web
    │                      ├─common
    │                      │  └─util
    │                      ├─home
    │                      │  └─module │ │ └─screen │ ├─servlet │ ├─store │ │ └─module │ │ ├─action │ │ ├─control │ │ └─screen │ └─user │ └─module │ ├─action │ └─screen └─webapp ├─common │ └─templates │ ├─layout │ └─screen ├─home │ ├─css │ ├─images │ └─templates │ ├─control │ ├─layout │ └─screen ├─META-INF │ └─autoconf ├─store │ ├─css │ ├─images │ └─templates │ ├─control │ ├─layout │ └─screen │ └─edit ├─user │ ├─css │ └─templates │ ├─control │ ├─layout │ └─screen └─WEB-INF ├─common │ └─$petstore_upload ├─home ├─store └─user

WEB-INF目錄


main下的兩個目錄分別是java和webapp。

從代碼結構來看,整個petstore-web分紅了3個模塊(子應用),分別是home、user、store等3個模塊。另外還有一個公共模塊common。

java部分

java部分在com.alibaba.sample.petstore.web下有四個主要的子包common、home、user、store,分別對應4個模塊。
而後在每一個子包下面纔是action、control、screen等module。

com.alibaba.sample.petstore.web.子模塊.module.action.LoginAction; com.alibaba.sample.petstore.web.子模塊.module.screen.LoginAction; com.alibaba.sample.petstore.web.子模塊.module.control.LoginAction;

webapp部分

webapp目錄下有4個子模塊目錄和WEB-INF目錄。
四個子模塊目錄分別是common、home、user、store。每一個裏面都是存放的該模塊的css、img、template等資源。

WEB-INF目錄下的內容:

  • web.xml
  • 3個子模塊目錄(每一個裏面都是form.xml),每一個子模塊對應一個webx-*.xml
  • 公共子目錄common,裏面存放了共用的配置文件;以及一個總的webx.xml

每一個子模塊的webx-*.xml中都有一個裝載模塊的配置<services:module-loader>,對應着java中的package。

例如webx-home.xml中的配置片斷是:<search-packages type="$1" packages="com.alibaba.sample.petstore.web.home.module.*" /> 例如webx-user.xml中的配置片斷是:<search-packages type="$1" packages="com.alibaba
相關文章
相關標籤/搜索