webx入门




• WebX的URL是怎样的呢?以下面的URL为例:
http://localhost:7001/petstore/user/account/edit.htm
– URL scheme(协议):http:
– Server name:localhost
– Server port:7001
– Context path:/petstore
– Component path:/user
– Servlet path:/account/edit.htm
– Target:/account/edit.vm

URL配置文件举例

<uri-config>
<!--外部链接-->
<uri name="toolkitSite" expose="true">
<serverURI>http://toolkit.alibaba-inc.com/</serverURI>
</uri>
<!--根据当前URL自动取得server name、port、context path等信息-->
<uri name="petstoreServer"/>
<!--指向user.car的URL -->
<turbine-uri name="userModule" expose="true" extends="petstoreServer">
<componentPath>/user</componentPath>
</turbine-uri>
<!--指向user.car中的图片、静态内容的URL -->
<turbine-content-uri name="userContent" expose="true" extends="userModule"/>
<!--指向user.car中的登录页面-->
<turbine-uri name="petstoreLoginLink" expose="true" extends="userModule">
<target>login.vm</target>
</turbine-uri>
</uri-config>
在模板中使用URIBroker的方法
•$toolkitSite
–生成结果:http://toolkit.alibaba-inc.com/
•$petstoreServer
–由于expose=false,所以不能直接使用
•$userModule.setTarget("account/edit.vm")
–生成结果:http://localhost:7001/petstore/user/account/edit.htm
•$userContent.setContentPath("images/my.gif")
–生成结果:http://localhost:7001/petstore/user/images/my.gif
•$petstoreLoginLink
–生成结果:http://localhost:7001/petstore/user/login.htm


do后缀

如果有这种情况http://localhost:8080/index.do,那么webx将不会查找index.vm这个模板,而是直接执行screen:xxx.module.screen.Index。

什么时候要使用这种URL呢:

  • 不使用模板的情形
  • 不需要返回可见的页面的情形
  • 重定向到另一个页面的情形
Webx应用的打包方法
• War —— 是Web Application Archive的缩写
• Car —— 是Component Archive的缩写
– 多个car可以组装成一个war

页面驱动
• 什么是页面驱动?
– 以页面(view)为主导
– 先写页面,再写和页面配套的程序模块
– 通过规则,查找页面所对应的程序模块
• 页面驱动的好处?
– 符合WEB项目开发的流程:
• 在产品设计阶段就可以做出页面
• 在开发阶段对页面进行细化。

RunData的功能

• 封装了Request和Response对象
• 保存request scope的状态
• 透明地处理常规表单和multipart/form-data格式的表单数据
• 简化cookie的存取
• 提供透明的buffering支持

• 取得HTTP request、response和session
– rundata.getRequest()
– rundata.getResponse()
– rundata.getSession()
• 取得输出流(自动buffering)
– rundata.getResponse().getWriter() – rundata.getResponse().getOutputStream()
• 取得query参数(无论是一般form还是multipart form)
– rundata.getParameters().getString("id")
– rundata.getParameters().getInt("quantity")
• 内部重定向
– rundata.setRedirectTarget("homepage.vm")
• 外部重定向
– rundata.setRedirectLocation("http://www.alibaba.com/")
• 设置content type和character encoding
– rundata.setContentType("text/html")
– rundata.setCharacterEncoding("UTF-8")
• 存取request scope的参数
– rundata.getAttribute(key)
– rundata.setAttribute(key, object)



参考:

webx入门

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值