从本章开始介绍一些常用的方法及组件
获得ServletContext
java类中:getDesktop().getWebApp().getNativeContext()
当然,这个类要继承zk的某个组件才行,例如Window
zul中:desktop.getWebApp().getNativeContext()
有了他,获得ApplicationContext就不在话下了:
ApplicationContext ctx =
WebApplicationContextUtils.getRequiredWebApplicationContext(
(ServletContext)getDesktop().getWebApp().getNativeContext());
zk的timeout
在WEB-INF/zk.xml中加入下边代码:
<session-config> <!-- 设置session过期时间,注意单位是秒--> <session-timeout>1800</session-timeout> <!-- Turn on the following if you want to reset the session-timeout counter when receiving onTimer, like any other request In other words, the session is never timeoout if the desktop has a timer.--> <!-- 上边的注释我翻译不好,我一般是注释掉的 --> <!--<timer-keep-alive>true</timer-keep-alive>--> </session-config> <device-config> <device-type>ajax</device-type> <!-- 设置timeout后跳转的页面 --> <timeout-uri>/timeout.zul</timeout-uri> </device-config>
下边转一个我在别的论坛看到的zk总结,比我总结的好多了!
原文地址:http://www.javaworld.com.tw/jute/post/view?bid=49&id=180896&tpg=1&ppg=1&sty=0&age=0
作者: rcblrcbl
原图放在附件里了