webx-URIBroker
来源:互联网 发布:淘宝平均停留时长 编辑:程序博客网 时间:2024/06/08 15:45
4.URIBroker的种类和配置
4.1.URIBroker
URIBroker定义了一个标准的URL中的所有部件:http :// user : pass @ myserver.com : 8080 /view ? id=1 # top
│ │ │ │ │ │ │ └─ reference、引用标记
│ │ │ │ │ │ └───── queryData、参数
│ │ │ │ │ └───────── path、路径
│ │ │ │ └──────────── serverPort、服务器端口
│ │ │ └───────────────────── serverName、服务器名
│ │ └────────────────────────── loginPassword、用户密码
│ └─────────────────────────────── loginUser、用户名
└──────────────────────────────────── scheme、协议
在配置文件中,<uri>定义了一个URIBroker对象:
<uri name="myURL" expose="true">
<scheme>http</scheme>
<serverName>localhost</serverName>
<serverPort>8080</serverPort>
<path>/xxx/yyy</path>
</uri>
为了简单起见,上面这段配置可以简写成:
<uri name="myURL" expose="true">
<serverURI>http://localhost:8080/xxx/yyy</serverURI>
</uri>
你可以在程序里使用它,例如:
URIBroker broker = getURIBrokerService().getURIBroker("myURL", rundata);
broker.addQueryData("id", "baobao");
你也可以在模板中使用它,例如:
$myURL.addQueryData("id", $user.id)
4.2.ServletURIBroker
ServletURIBroker是从URIBroker派生的,因此前述URIBroker的使用方法同样适用于ServletURIBroker。但是ServletURIBroker针对Java Web应用扩展了标准URL的path部分:
http://user:pass@myserver.com:8080
/myapp /myservlet /xxx/yyy ?id=1#top
│ │ │ │ └─── 同URIBroker
│ │ │ └──────── path、path的剩余部分
│ │ └────────────── servletPath、代表servlet映射
│ └────────────────── contextPath、代表WEB应用
└─────────────────────────────────── 同URIBroker
在配置文件中,<servlet-uri>定义了一个ServletURIBroker对象。
<servlet-uri name="myURL">
<contextPath>/myapp</contextPath>
<servletPath>/myservlet</servletPath>
<path>/xxx/yyy</path>
</servlet-uri>
你可以在程序里使用它,例如:
ServletURIBroker broker = (ServletURIBroker) getURIBrokerService().getURIBroker("myURL", rundata);
broker.setContextPath("/myapp");
你也可以在模板中使用它,例如:
$myURL.setContextPath("/myapp")
4.3.TurbineURIBroker
TurbineURIBroker又在ServletURIBroker的基础上,扩展了其path部分:
http://user:pass@myserver.com:8080/myapp/myservlet
/mycar /target /xxx/yyy ?id=1#top
│ │ │ │ └─── 同URIBroker
│ │ │ └──────── path、path的剩余部分
│ │ └──────────── target,代表执行目标
│ └──────────────── componentPath、代表car
└──────────────────────────────────────── 同ServletURIBroker
在配置文件中,<turbine-uri>定义了一个TurbineURIBroker对象。
<turbine-uri name="myURL">
<contextPath>/myapp</contextPath>
<componentPath>/mycar</componentPath>
<target>viewUser.vm</target>
</turbine-uri>
你可以在程序里使用它,例如:
TurbineURIBroker broker = (TurbineURIBroker) getURIBrokerService().getURIBroker("myURL", rundata);
broker.setContextPath("/myapp");
broker.setComponentPath("/mycar");
broker.setTarget("viewUser.vm");
你也可以在模板中使用它,例如:
$myURL.setTarget("viewUser.vm")
4.4.其它URIBroker
其实,所有的URIBroker的用法都差不多。它们的类层次结构如下,右边是其在配置文件中对应的标签。
类层次 配置文件中,对应的标签
URIBroker <uri>
├── ContentURIBroker <content-uri>
└── ServletURIBroker <servlet-uri>
├── ServletContentURIBroker <servlet-content-uri>
├── TurbineClassicURIBroker <turbine-classic-uri>
└── WebxURIBroker
├── TurbineURIBroker <turbine-uri>
└── TurbineContentURIBroker <turbine-content-uri>
你可以通过某个URIBroker及其子类的文档,以及API接口,了解这种URIBroker的用法。
另外,你也可以参考URIBrokerService的文档,来更深入和详细地了解URIBrokerService以及URIBroker。
5.URL的解析
和生成URL相反的过程,就是URL的解析。如前所述,URL的解析是通过Java Servet容器(即应用服务器)和AnalyseURLValve配合,共同完成的。
在URL的解析过程中,我们还做了一些特殊的转换。
5.1.Target后缀转换假如我们的URL为:http://localhost:8080/workshop/hello.htm,那么我们将得到值为hello.vm的target。当你使用URIBroker输出hello.vm这个target时,它又会被转换成hello.htm。这种双向的转换确保了:
5.1.1. URL的后缀可随意更换。这种定制不会影响到应用程序或模板。
5.1.2. 应用程序或模板中,永远使用target后缀(这里是.vm),而不需要了解URL的后缀。
事实上,这个映射是由MappingService来完成的。除了htm óvm的转换,我们还预定义了好几种后缀。
URL后缀
Target后缀
说明
php(正式)
?
jhtml
php
通常代表JSP模板
ó
jsp(正式)
jhtml
jsp
?
htm(正式)
?
vhtml
htm
通常代表Velocity模板
ó
vm(正式)
vhtml
vm
?
其它后缀或无后缀
ó
不改变
例如:*.do ó*.do
5.2.大小写转换
为了提高兼容性,我们对URL、Query参数按照一定的规则进行大小写转换。
下面是URL的转换规则:
URL
(lower case with underscore)
Target
(camel case)
模板名
(camel case)
类名
(pascal case)
/view_user.*
ó
/viewUser.*
/viewUser.*
ViewUser
/viewUser.*
/ViewUser.*
/VIEW_USER.*
/viewUSER.*
?
下面是query参数的转换规则:
Query参数
(lower case with underscore)
Request.getParameter
(camel case)
user_id=123(正式)
userId=123
UserId=123
USER_ID=123
userID=123
?
request.getParameter("user_id") == "123"
request.getParameter("userId") == "123"(正式)
request.getParameter("UserId") == "123"
request.getParameter("USER_ID") == "123"
request.getParameter("userID") == "123"
注意,在Webx中,rundata.getParameters().getString()等同于request.getParameter()。
- webx-URIBroker
- URIBroker Service
- webX
- Webx
- webx
- webx- webx framework
- Webx-webx turbine
- webx解析
- Webx SpringExt
- webx概念
- WebX基础知识
- webx学习
- webx 学习
- webx入门
- webx小结
- Webx配置文件
- Webx介绍
- Webx是什么?
- 典型负反馈放大电路
- 顺序栈
- 项目中类显示红色下划线
- ecshop二次开发--百度地图
- 安卓易学,爬坑不易—腾讯老司机的RecyclerView局部刷新爬坑之路
- webx-URIBroker
- 机器学习之由wavenet涉及到的基础知识(补充下学习ing)
- OpenMAX_IL_1_2_0_Specification--概述
- MD5c++代码
- 修复 Unsupported major.minor version 52.0 Error in Java
- ssm+shiro基础框架搭建(一)
- 关于文本模式设置为ie7列表不能显示出来,i9以上可以
- matlab安装Robotics Toolbox
- 时间戳和字符串互相转换,以及时间戳转换成时间