在jsp中使用zk时,我用的是ZkJsp Tags1.4.0 RC中的包,如果真要在jsp中使用zk或者混用*.zul和*.jsp,最好不要用1.3.0的版本,这个版本很多BUG,虽然1.4.0的是rc版,但是个人观点比1.3.0强多了,比如doInit方法,zk也太牛逼了,把类的方法改了,竟然在1.3.0中做相应的改变还是不能用。
上面的四篇关于数据传输的文章是我做在一个工程里的,比较乱,然后就分别拿出来了,上面的例子有实现了一个CRUD,然后还有其他的一些细节还是值得借鉴的,一直在查英文资料,再怎么说也是整理了3天的结果,拿出来共享了。zk的中文资料太少,而且大部分都是介绍的3.6.3之前的版本,希望这几篇能对看文章的朋友有所帮助。
总之,学了3天左右,终于现在能比较熟练地使用hibernate,spring,jsp和zk了,唉,整合太麻烦!
把web.xml贴下面了(mime那些可以不要,不过以后要配置的话可以参考一下):
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <description><![CDATA[ZK Demo]]></description> <display-name>zkcrud</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>WEB-INF/applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <!-- The Spring RequestContextLister uses thread bound variables so to use this Spring freatures requires that we apply <disable-event-thread /> within zk.xml --> <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> </listener> <!-- //// --> <!-- ZK --> <listener> <description> Used to cleanup when a session is destroyed</description> <display-name> ZK Session Cleaner</display-name> <listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class> </listener> <listener> <description>ZK JspTags EL environment initiation </description> <display-name>ZK Jsp Factory initiator</display-name> <listener-class>org.zkoss.jsp.spec.JspFactoryContextListener</listener-class> </listener> <servlet> <description>ZK loader for ZUML pages</description> <servlet-name>zkLoader</servlet-name> <servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class> <!-- Must. Specifies URI of the update engine (DHtmlUpdateServlet). It must be the same as <url-pattern> for the update engine. --> <init-param> <param-name>update-uri</param-name> <param-value>/zkau</param-value> </init-param> <!-- Optional. Specifies the default log level: OFF, ERROR, WARNING, INFO, DEBUG and FINER. If not specified, the system default is used. <init-param> <param-name>log-level</param-name> <param-value>OFF</param-value> </init-param> --> <load-on-startup>1</load-on-startup><!-- Must --> </servlet> <servlet-mapping> <servlet-name>zkLoader</servlet-name> <url-pattern>*.zul</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>zkLoader</servlet-name> <url-pattern>*.zhtml</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>zkLoader</servlet-name> <url-pattern>*.zxml</url-pattern> </servlet-mapping> <!-- Optional. Uncomment it if you want to use richlets. --> <servlet-mapping> <servlet-name>zkLoader</servlet-name> <url-pattern>/zk/*</url-pattern> </servlet-mapping> <servlet> <description>The asynchronous update engine for ZK</description> <servlet-name>auEngine</servlet-name> <servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class> </servlet> <servlet> <description> The servlet loads the DSP pages.</description> <servlet-name>dspLoader</servlet-name> <servlet-class> org.zkoss.web.servlet.dsp.InterpreterServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>auEngine</servlet-name> <url-pattern>/zkau/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>dspLoader</servlet-name> <url-pattern>*.dsp</url-pattern> </servlet-mapping> <!-- Uncomment if you want to use the ZK filter to post process the HTML output generated by other technology, such as JSP and velocity. <filter> <filter-name>zkFilter</filter-name> <filter-class>org.zkoss.zk.ui.http.DHtmlLayoutFilter</filter-class> <init-param> <param-name>extension</param-name> <param-value>html</param-value> </init-param> </filter> <filter-mapping> <filter-name>zkFilter</filter-name> <url-pattern>/test/filter.dsp</url-pattern> </filter-mapping> <filter-mapping> <filter-name>zkFilter</filter-name> <url-pattern>/test/filter2.dsp</url-pattern> </filter-mapping> --> <!-- ///////////// --> <!-- DSP (optional) --> <!-- Uncomment if you want to use Potix DSP in your Website <servlet> <servlet-name>dspLoader</servlet-name> <servlet-class>org.zkoss.web.servlet.dsp.InterpreterServlet</servlet-class> <init-param> <param-name>class-resource</param-name> <param-value>true</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>dspLoader</servlet-name> <url-pattern>*.dsp</url-pattern> </servlet-mapping> --> <!-- /////////// --> <!-- Miscellaneous --> <session-config> <session-timeout>120</session-timeout> </session-config> <!-- MIME mapping --> <mime-mapping> <extension>doc</extension> <mime-type>application/vnd.ms-word</mime-type> </mime-mapping> <mime-mapping> <extension>gif</extension> <mime-type>image/gif</mime-type> </mime-mapping> <mime-mapping> <extension>htm</extension> <mime-type>text/html</mime-type> </mime-mapping> <mime-mapping> <extension>html</extension> <mime-type>text/html</mime-type> </mime-mapping> <mime-mapping> <extension>jad</extension> <mime-type>text/vnd.sun.j2me.app-descriptor</mime-type> </mime-mapping> <mime-mapping> <extension>jnlp</extension> <mime-type>application/x-java-jnlp-file</mime-type> </mime-mapping> <mime-mapping> <extension>jpeg</extension> <mime-type>image/jpeg</mime-type> </mime-mapping> <mime-mapping> <extension>jpg</extension> <mime-type>image/jpeg</mime-type> </mime-mapping> <mime-mapping> <extension>js</extension> <mime-type>application/x-javascript</mime-type> </mime-mapping> <mime-mapping> <extension>pdf</extension> <mime-type>application/pdf</mime-type> </mime-mapping> <mime-mapping> <extension>png</extension> <mime-type>image/png</mime-type> </mime-mapping> <mime-mapping> <extension>rar</extension> <mime-type>application/x-rar-compressed</mime-type> </mime-mapping> <mime-mapping> <extension>txt</extension> <mime-type>text/plain</mime-type> </mime-mapping> <mime-mapping> <extension>xls</extension> <mime-type>application/vnd.ms-excel</mime-type> </mime-mapping> <mime-mapping> <extension>xml</extension> <mime-type>text/xml</mime-type> </mime-mapping> <mime-mapping> <extension>xul</extension> <mime-type>application/vnd.mozilla.xul-xml</mime-type> </mime-mapping> <mime-mapping> <extension>zhtml</extension> <mime-type>text/html</mime-type> </mime-mapping> <mime-mapping> <extension>zip</extension> <mime-type>application/x-zip</mime-type> </mime-mapping> <mime-mapping> <extension>zul</extension> <mime-type>text/html</mime-type> </mime-mapping> <welcome-file-list> <welcome-file>index.zul</welcome-file> <welcome-file>index.zhtml</welcome-file> <welcome-file>index.mil</welcome-file> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>