webx3核心配置

Webx3 服务配置
1 RequestContext
<!-- 设置request/response/session。 -->
<services:request-contexts
    xmlns="http://www.alibaba.com/schema/services/request-contexts">
        <buffered />
        <lazy-commit />
        <parser />
        <set-locale defaultLocale="zh_CN" defaultCharset="UTF-8" />
        <session>
            <id>
                <cookie path="/" maxAge="0" httpOnly="true" />
            </id>
            <stores>
                <session-stores:cookie-store id="temporaryCookie">
                    <session-stores:cookie name="tmp" />
                </session-stores:cookie-store>
            </stores>
            <store-mappings>
                <match name="*" store="temporaryCookie" />
            </store-mappings>
        </session>
</services:request-contexts>
2 PipeLine.xml
<services:pipeline xmlns=http://www.alibaba.com/schema/services/pipeline/valves>
        <!-- 初始化turbine rundata,并在pipelineContext中设置可能会用到的对象(如rundata、utils),以便valve取得。 -->
        <prepareForTurbine />
        <!-- 预备webx所需的对象。 -->
        <prepareForWebx2 />
        <setLoggingContext />
        <!-- 分析URL,取得target。 -->
        <analyzeURL homepage="homepage" />
        <checkCsrfToken />
         <loop>
               … Valve
         </loop>
    </services:pipeline>
<services:pipeline xmlns=http://www.alibaba.com/schema/services/pipeline/valves>
    ………
    <loop>
            <choose>
                <when>
<pl-conditions:target-extension-condition extension="null, vm, jsp" />
                    <performAction />
                    <performTemplateScreen />
                    <renderTemplate />
                </when> 
                <when>
                   <pl-co ditions:target-extension-condition extension="do" />
                    <performAction />
                    <performScreen />
                </when>
                <otherwise>
                    <!-- 将控制交还给servlet engine。 -->
                    <exit />
                </otherwise>
            </choose>
         <breakUnlessTargetRedirected />
        </loop>
    </services:pipeline>
3 ModuleLoader
<!-- 装载模块。 -->
    <services:module-loader>
        <ml-factories:class-modules>
            <ml-factories:search-packages type="$1"
                packages="com.alibaba.sample.petstore.web.admin.module.*"
                includeAbstractClasses="true" />
       </ml-factories:class-modules>
        <ml-adapters:webx2-module-adapter />
    </services:module-loader>
4 PullService
<services:pull xmlns="http://www.alibaba.com/schema/services/pull/tools">
        <!-- 全局tools。 -->
        <services:tools>
            <!-- Webx3 tools。 -->
            <utils />
            <rundata-tool />
            <csrfToken />
        </services:tools>
        <!-- 每个request都会创建一次的tools。 -->
        <services:tools scope="request">
            <!-- Webx3 tools。 -->
            <control-tool />
            <!-- Webx2 tools。 -->
            <webx2-tool id="form" class="com.alibaba.service.form.FormTool" />
            <webx2-tool id="uri" class="com.alibaba.service.uribroker.URIBrokerTool" />
        </services:tools>
        <!-- 每个request都会创建一次的tools,但components之间共享同一个实例。 -->
        <services:tools scope="request" shareWithComponents="true">
            <!-- Webx3 tools。 -->
            <page-tool />
        </services:tools>
    </services:pull>
5  MappingRule
<services:mapping-rules xmlns="http://www.alibaba.com/schema/services/mapping-rules">
       <direct-module-rule id="action" />
        <!-- Target name => Screen module name (*.do) -->
        <direct-module-rule id="screen.notemplate" />
        <!-- Target name => Screen module name (*.jsp, *.vm) -->
        <fallback-module-rule id="screen" moduleType="screen" />
        <!-- Target name => Screen template name -->
        <direct-template-rule id="screen.template" templatePrefix="screen" />
        <!-- Target name => Layout template name -->
        <fallback-template-rule id="layout.template" templatePrefix="layout" />
        <!-- Target name => Control module name (setControl method) -->
        <direct-module-rule id="control.notemplate" />
        <fallback-module-rule id="control" moduleType="control" />
        <direct-template-rule id="control.template" templatePrefix="control" />
    </services:mapping-rules>
6 DataResolver
<!-- 支持注入参数,可以在这里扩展自己的参数绑定器 -->
    <services:data-resolver xmlns="http://www.alibaba.com/schema/services/data-resolver/factories">
        <turbine-rundata-resolver />
        <parameter-resolver />
        <form-resolver />
    </services:data-resolver>
7 Form
<services:form>
        <services:group name="addProduct">
            <services:field name="productId" displayName="产品ID">
                <required-validator>
                    <message>必须填写${displayName}</message>
                </required-validator>
                <custom-error id="duplicatedProductId">
                    <message>产品ID和已有产品冲突</message>
                </custom-error>
            </services:field>
          services:field name="picture" displayName="产品图片">
                <required-validator>
                    <message>必须上传产品图片</message>
                </required-validator>
                <uploaded-file-validator
                    contentType="image/gif, image/jpeg, image/pjpeg, image/jpg, image/png">
                    <message>${displayName}不是合法的图片文件</message>
                </uploaded-file-validator>
                <uploaded-file-validator maxSize="100K">
                    <message>${displayName}不能超过${maxSize}字节</message>
                </uploaded-file-validator>
            </services:field>
        </services:group>
    </services:form>
8 Rewrite
<services:request-contexts id="rewrite" sort="false">
  <parser />
    <rewrite>
    <!-- 永久重定向,301   -->
    <rule pattern="/test1/hello.htm">
    <substitution uri="/test1/new_hello.htm" flags="L,R=301" />
    </rule>
    <!-- 临时重定向,302,不保留参数   -->
    <rule pattern="/test2/hello.htm">
    <substitution uri="/test2/new_hello.htm" flags="L,R" />
    </rule>
    <!-- 临时重定向,302,保留参数   -->
    <rule pattern="/test2.4/hello.htm">
    <substitution uri="/test2.4/new_hello.htm" flags="L,R,QSA" />
    </rule>

你可能感兴趣的:(Web)