`

【ZK开发】环境搭建

    博客分类:
  • ZK
阅读更多

一,为什么要写【ZK开发】系列文章

 

 

 使用zk开发,已经2年多了,从zk3.0到现在以及即将发布的zk5.0.3,只因没有写blog的习惯,很多知识点都是使用脑细胞去记忆,随着时间的推移,它们早晚有一天将不复存在,好脑子不如烂笔头,特此记下,以方便日后查阅

 

 

二,准备

 

 

1,运行环境

 

eclipse3.5 + 

 

jdk1.6 +

 

Tomcat6 +

 

Tomcat eclipse Plug-in  附件内 点这里

 

2,ZK版本的选择

 

zk5之前的版本为免费版,从zk5开始,分化出免费社区CE版,收费PE专业版,EE企业版,详细区别见这里,根据自己所需功能和费用承受能力选择

 

3,Zk学习

 

首先我们要了解zk的架构、组件、页面、桌面、事件、执行流程、运行机制等等基本概念,对Zk有一个基本轮廓及具体概念的把握。以下是学习资源:

 

 

 

 

 

 

 

 

三,环境搭建

 

1,基于环境与版本:内容基于(二)1中环境,Zk版本选择5.0.2 CE版

 

2,设置java源码编码方式:源码的编码用utf-8格式,

 

具体配置: Window menu --> Preferences  --> Generals   --> Content Types  --> Text  --> Java Source File  --> Default Encoding  --> Update  --> OK

 

3,tomcat插件配置:将附件内 tomcat 插件copy到eclipse目录D:\eclipse\plugins,重启tomcat

 

    关联Tomcat:  Window menu --> Preferences  --> Tomcat   -->  Tomcat Version   --> Tomcat6.x   --> Tomcat Home   --> Brower >选择安装的Tomcat根目录   --> Context declaration mode   -->  Context files   -->  ok 

 

4, 创建Zk项目:File menu   --> new   --> Dynamic Web Project     --> 输入Project Name ,本例输入zk5

 

关键步骤:由于eclipse默认java文件编译后放在zk5/build/classes文件中,实际使用时,我们应该让其编译到

 

zk5/WebContent/WEB-INF/classes 目录内

 

如何修改:  zk5项目上右键 --> Properties  -->  Java Build Path --> Source选项卡,在视图最下 Default output folder输入zk5/WebContent/WEB-INF/classes保存

 

如果未配置以上内容,一般会出现  xxxx.class is NotFoundException

 

 

5,复制相应jar及配置文件到web-inf/lib目录内,最终目录结构如下图

 

 

 

web.xml内容如下:

 

 

 

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
	<!--
		Spring ApplicationContext
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>
			/WEB-INF/config/spring/applicationContext-linkFax.xml /WEB-INF/config/spring/applicationContext.xml
		</param-value>
	</context-param>
	
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>  -->
	<!--
		Spring 刷新Introspector防止内存泄露
	<listener>
		<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
	</listener> -->
	
	<!-- //// -->
	<!-- ZK -->
	<listener>
		<description>ZK listener for session cleanup</description>
		<listener-class>org.zkoss.zk.ui.http.HttpSessionListener</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 whether to compress the output of the ZK loader.
			It speeds up the transmission over slow Internet. However, if you
			configure a filter to post-processing the output, you might have to
			disable it. Default: true <init-param>
			<param-name>compress</param-name> <param-value>true</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>*.svg</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>zkLoader</servlet-name>
		<url-pattern>*.xml2html</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>
		<!--
			[Optional] Specifies the AU processor for particular prefix.
			<init-param> <param-name>processor0</param-name>
			<param-value>/upload=com.my.MyUploader</param-value> </init-param>
		-->
	</servlet>
	<servlet-mapping>
		<servlet-name>auEngine</servlet-name>
		<url-pattern>/zkau/*</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> <init-param>
		<param-name>compress</param-name> <param-value>true</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) -->
	<!-- We need it to show zkdemo correctly (due to categorybar.dsp)
	
	<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>60</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>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>/WEB-INF/content/index.zul</welcome-file>
		<welcome-file>/WEB-INF/content/index.htm</welcome-file>
	</welcome-file-list>
</web-app>
 

 

 

zk.xml内容如下

 

 

<?xml version="1.0" encoding="UTF-8"?>
<zk>
	<!--
		Turn on if you want to debug JavaScript. Once turned on, the
		uncompressed JavaScript files will be loaded.
	-->
	<client-config>
		<debug-js>true</debug-js>
	</client-config>
	<!--
		Turn on if you want to debug by copying JavaScript files directly to
		classpath <desktop-config>
		<extendlet-check-period>5</extendlet-check-period> </desktop-config>
	-->

	<!--
		Turn on if you want to JSP 2.1 EL as the default interpreter
		<xel-config>
		<evaluator-class>org.zkoss.zkmax.xel.el21.ApacheELFactory</evaluator-class>
		</xel-config>
	-->
	<!--
		Uncomment if you turn off the caching of resources loaded from the
		class path (aka., class Web resources). By default, class Web
		resources are cached by the browser until you upgraded ZK to a newer
		version. However, it is better to turn the cache off when you are
		developing a theme or a component. <library-property>
		<name>org.zkoss.web.classWebResource.cache</name> <value>false</value>
		</library-property>
	-->

	<!--
		Uncomment if you want to control the number of hours that the CSS
		files of class Web resources won't be changed. By default, it is 8760
		(the same as other class Web resouces). A non-positive value turns off
		the cache of the CSS files of class Web resources. This property is
		meaningless if org.zkoss.web.classWebResource.cache is disabled.
		<library-property>
		<name>org.zkoss.web.classWebResource.cache.CSS.days</name>
		<value>8760</value> </library-property>
	-->
	<!--
		The allowed child elements include evaluator-class. At most one
		xel-config element is allowed for each zk.xml. <xel-config>
		<evaluator-class>my.MyExpressionFactory</evaluator-class>
		</xel-config>
	-->
	<!--
		Turn on if you want to generate UUID by prefixing ID with the value
		specified here. It is designed for testing purpose. Notice ${page will
		be replaced with page's UUID. If you don't want it, remove it.
		<desktop-config> <id-to-uuid-prefix>_zid_${page}_</id-to-uuid-prefix>
		</desktop-config>
	-->
	<!--
		Turn on if you want to use the same UUID sequence for the desktops
		after reboot. It is mainly for testing purpose. <desktop-config>
		<repeat-uuid>true</repeat-uuid> </desktop-config>
	-->
	<!--
		<log> <description>[Optional] Monitor i3-log.conf and register a
		handler for the specified log-base</description>
		<log-base>org.zkoss</log-base> </log>
	-->

	<!--
		Turn on the following if you want to use the trendy mold as default
		for all buttons.
	-->
	<library-property>
		<name>org.zkoss.zul.Button.mold</name>
		<value>trendy</value>
	</library-property>

	<!--
		Turn on the following if want to use auto as the default.

		<library-property> <name>org.zkoss.zul.include.mode</name>
		<value>auto</value> </library-property>
	-->
	<!--
		Turn on if you want to use language addons. <language-config>
		<addon-uri>/WEB-INF/lang-addon.xml</addon-uri> </language-config>
	-->
	<!--
		Turn on if the processing time is longer than 9000 miliseconds.
		http://docs.zkoss.org/wiki/Developer_reference_Appendix_B._WEB-INF/zk.xml_Overview_The_client-config_Element#The_resend-delay_Element
		<client-config> <resend-delay>9000</resend-delay> <client-config>
	-->
	<!--
		Turn on if you want to ignore the consecutive click events, if it
		happens too close to the previous one, or the server is still serving
		the previous click. <client-config>
		<click-filter-delay>390</click-filter-delay> </client-config>
	-->

	<!--
		[ZK EE] Turn on if you want to enable the render-on-demand feature for
		grid. It improves the performance for huge grid. Default: false
	-->
	<library-property>
		<name>org.zkoss.zul.grid.rod</name>
		<value>true</value>
	</library-property>
	<!--
		[ZK EE] Turn on if you want to enable the render-on-demand feature for
		listbox. It improves the performance for huge listbox. Default: false
	-->
	<library-property>
		<name>org.zkoss.zul.listbox.rod</name>
		<value>true</value>
	</library-property>

	<!--
		[ZK EE] Turn on if you want to block the requests sent from
		inaccessible widgets (such as invisible or disabled). It is used to
		protect your application from the attack that goes through the
		invisible widgets. Once turned on, the request from an invisible
		widget is blocked. See also org.zkoss.zkmax.au.IWBS.events <listener>
		<listener-class>org.zkoss.zkmax.au.InaccessibleWidgetBlockService$DesktopInit</listener-class>
		</listener>
	-->
	<!--
		[ZK EE] Turn on if you use InaccessibleWidgetBlockService (IWBS) and
		want to block only particular events. Default: all <library-property>
		<name>org.zkoss.zkmax.au.IWBS.events</name>
		<value>onClick,onChange,onSelect</value> </library-property>
	-->

	<!--
		[ZK EE] Turn on if you want to recycle the desktop if an user
		navigates back to the same URL <listener>
		<listener-class>org.zkoss.zkmax.ui.util.DesktopRecycle</listener-class>
		</listener>
	-->

	<!--
		[ZK EE] Turn on if you want to make your Web application crawlable
		(indexed) by search engines. <system-config>
		<crawlable>true</crawlable> </system-config>
	-->


	<!-- Optional -->
	<!--
		Map extensions to the xml language. By default, xml is mapped to xml
		<language-mapping> <language-name>xml</language-name>
		<extension>svg</extension> </language-mapping> <language-mapping>
		<language-name>xml</language-name> <extension>xml2html</extension>
		</language-mapping>
	-->
	<!--
		Map extensions to the xul/html language By default, xul/html are
		mapped to zul and xul. <language-mapping>
		<language-name>xul/html</language-name> <extension>xxx</extension>
		</language-mapping>
	-->

	<session-config>
		<!--
			Turn on the following if you want a different timeout Note: The unit
			is seconds (while that of web.xml is minute)
			<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>
	<session-config>
		<!--
			Uncomment it and set it to mil, if you want to configure for a mobile
			device. If omitted, ajax is ASSUMED. Currently, only timeout-uri and
			automatic-timeout support per-device configuration.
			<device-type>ajax</device-type>

			<timeout-uri>/timeout.zul</timeout-uri>
		-->
		<!-- An empty URL can cause the browser to reload the same URL -->

		<!--
			Uncomment the following if you want to automatically redirect to the
			timeout page. By default, it is triggered by the user after timeout
			(such as clicking). <automatic-timeout/>
		-->
	</session-config>


	<!--
		We turn on the event processing thread in zkdemo to demostrate
		features that are available only if the eventprocessing thread is
		turned on. However, the event processig thread is disabled by default
		since ZK 5.0, to be complaint with Java Servlet specification. It is
		recommended to disable if you intend to integrate Spring web flow and
		other sophisticated frameworks. <system-config>
		<disable-event-thread>false</disable-event-thread> </system-config>
	-->
	<!--
		Turn on the following if you want to use ZK with a clustering server
		or cloud environment (such as Google App Engine) <system-config>
		<disable-event-thread/>
		<ui-factory-class>org.zkoss.zk.ui.http.SerializableUiFactory</ui-factory-class>
		</system-config>
	-->
	<!--
		Disable the serialization of BeanShell methods Default: enable Disable
		it if Google App Engine is used since it cannot serialize BeanShell
		method correctly <library-property>
		<name>org.zkoss.zk.scripting.bsh.method.serializable</name>
		<value>false</value> </library-property>
	-->
	<!--
		Turn on the following if you want to cache all desktops in a global
		cache, rather than one for each session <system-config>
		<cache-provider-class>org.zkoss.zk.ui.sys.GlobalDesktopCacheProvider</cache-provider-class>
		</system-config>
	-->
	<!--
		<system-config> <au-writer-class>my.AuWriter</au-writer-class>
		<cache-provider-class> my.CacheProvider </cache-provider-class>
		<disable-event-thread /> <engine-class> my.UiEngine </engine-class>
		<failover-manager-class> my.FailoverManager </failover-manager-class>
		<id-generator-class> my.IdGenerator </id-generator-class>
		<max-spare-threads> 100 </max-spare-threads> <max-suspended-threads>
		100 </max-suspended-threads> <max-upload-size> 5120 </max-upload-size>
		<max-process-time> 3000 </max-process-time> <response-charset> UTF-8
		</response-charset> <session-cache-class> my.SessionCache
		</session-cache-class> <upload-charset> UTF-8 </upload-charset>
		<upload-charset-finder-class> my.CharsetFinder
		</upload-charset-finder-class> <ui-factory-class> my.UiFactory
		</ui-factory-class> <url-encoder-class> my.URLEncoder
		</url-encoder-class> <web-app-class> my.WebApp </web-app-class>
		</system-config>
	-->
	<!-- Optional -->
	<!--
		You can define any number of richlets as follows. Note: To use
		richlet, you have to map zkLoader to /xx/* in web.xml, where xx could
		be any name. And, the final URL will be /xx/url-pattern. This demo
		application maps all richlet to /zk (see web.xml), so the richlet path
		will be, say, /zk/test/some
	-->
	<!--
		<richlet> <richlet-name>Test</richlet-name>
		<richlet-class>org.zkoss.zkdemo.test.TestRichlet</richlet-class> Any
		number of initial parameters. <init-param>
		<param-name>any</param-name> <param-value>any</param-value>
		</init-param> </richlet> <richlet-mapping>
		<richlet-name>Test</richlet-name> <url-pattern>/test/*</url-pattern>
		</richlet-mapping>
	-->
	<!-- Optional -->
	<!--
		<device-config> <device-type>ajax</device-type>
		<timeout-uri>/timeout.zul</timeout-uri> An empty URL can cause the
		browser to reload the same URL </device-config>
	-->

	<!--
		Uncomment if you want to embed JavaScript codes and any other tags to
		be generated inside HTML HEAD. <device-config>
		<device-type>ajax</device-type> <embed><![CDATA[ <script
		type="text/javascript"> </script> ]]></embed> </device-config>
	-->

	<!-- Optional -->
	<!--
		the following listener is used to see # of sessions, desktops...
	-->
	<listener>
		<description>[Optional] Mointor the statistic</description>
		<listener-class>org.zkoss.zk.ui.util.Statistic</listener-class>
	</listener>


	<!--
		Configure the error page <error-page>
		<device-type>['''ajax'''|mil]</device-type>
		<exception-type>java.lang.Throwable</exception-type>
		<location>/WEB-INF/sys/error.zul</location> </error-page>
	-->


	<!--
		Configure ZUL to use smaller fonts for all locales, and smaller fonts
		for the rest Locales <desktop-config>
		<disable-theme-uri>~./zul/css/norm*.css.dsp*</disable-theme-uri>
		<theme-uri>~./zul/css/normsm*.css.dsp*</theme-uri> </desktop-config>
	-->
	<!--
		Configure ZUL to use larger fonts for all locales, and smaller fonts
		for the rest Locales <desktop-config>
		<disable-theme-uri>~./zul/css/norm*.css.dsp*</disable-theme-uri>
		<theme-uri>~./zul/css/normlg*.css.dsp*</theme-uri> </desktop-config>
	-->
	<!--
		Configure ZUL to use larger fonts for Chinese characters, and nomal
		fonts for the rest Locales <desktop-config>
		<disable-theme-uri>~./zul/css/norm*.css.dsp*</disable-theme-uri>
		<theme-uri>~./zul/css/norm**.css.dsp</theme-uri> </desktop-config>
	-->
	<!--
		Configure additional theme URIs <desktop-config>
		<theme-uri>/a.css</theme-uri> <theme-uri>/b**.css</theme-uri>
		</desktop-config>
	-->
	<!--
		<desktop-config>
		<theme-provider-class>org.zkoss.zkdemo.userguide.FontSizeThemeProvider</theme-provider-class>
		</desktop-config>
	-->
	<!--
		Uncomment the following if you want to redirect to particular page
		when ZK Client receives an error code. <client-config> <error-reload>
		<error-code>301</error-code> <reload-uri>/login.zul</reload-uri>
		</error-reload> </client-config>
	-->

	<!--
		Uncomment the following to customize the client-polling-based server
		push. Note: the unit of PollingServerPush.delay.min and max is second.
		Note: the values of PollingServerPush.start and stop are the
		JavaScript codes to execute at the client. Note: the value of
		PollingServerPush.delay.factor must be integer, <preference>
		<name>PollingServerPush.delay.min</name> <value>3000</value>
		</preference> <preference> <name>PollingServerPush.delay.max</name>
		<value>10000</value> </preference> <preference>
		<name>PollingServerPush.delay.factor</name> <value>5</value>
		</preference> <preference> <name>PollingServerPush.start</name>
		<value></value> </preference> <preference>
		<name>PollingServerPush.stop</name> <value></value> </preference>
	-->

	<!--
		Configure the default font size in ZUL CSS file (norm*.css) Default:
		12px.
	-->
	<library-property>
		<name>org.zkoss.zul.theme.fontSizeM</name>
		<value>12px</value>
	</library-property>

	<!--
		Configure the font size for menus in ZUL CSS file (norm*.css) Default:
		11px.
	-->
	<library-property>
		<name>org.zkoss.zul.theme.fontSizeMS</name>
		<value>12px</value>
	</library-property>

	<!--
		Configure the font size for smaller fonts, such as toolbar, in ZUL CSS
		file (norm*.css) Default: 11px.
	-->
	<library-property>
		<name>org.zkoss.zul.theme.fontSizeS</name>
		<value>12px</value>
	</library-property>

	<!--
		Configure the font size for extremely small fonts, in ZUL CSS file
		(norm*.css) Default: 10px. <library-property>
		<name>org.zkoss.zul.theme.fontSizeXS</name> <value>12px</value>
		</library-property>
	-->
	<!--
		Configure the font family for titles in ZUL CSS file (norm*.css)
		Default: Verdana, Tahoma, Arial, Helvetica, sans-serif.
		<library-property> <name>org.zkoss.zul.theme.fontFamilyT</name>
		<value>Verdana, Tahoma, Arial, Helvetica, sans-serif</value>
		</library-property>
	-->
	<!--
		Configure the font family for content in ZUL CSS file (norm*.css)
		Default: Verdana, Tahoma, Arial, serif. <library-property>
		<name>org.zkoss.zul.theme.fontFamilyC</name> <value>Verdana, Tahoma,
		Arial, Helvetica, sans-serif</value> </library-property>
	-->

	<!--
		Configure ZUL not to override the standard HTML tags, such as body's
		margin and padding <library-property>
		<name>org.zkoss.zul.theme.browserDefault</name> <value>true</value>
		</library-property>
	-->
	<!--
		Configure ZUL to apply the zk prefix in the CSS file (norm*.css). Use
		this only if you want to use different fonts for ZK components and the
		rest of your Web pages <library-property>
		<name>org.zkoss.zul.theme.enableZKPrefix</name> <value>true</value>
		</library-property>
	-->

	<!--
		Uncommet to control the number of lines to log an error message.
		Default: 6. If nonpostive is specified, the full stack traces are
		logged. Notice that # of lines don't include packages starting with
		java, javax or sun. <library-property>
		<name>org.zkoss.util.logging.realCauseBriefly</name> <value>0</value>
		</library-property>
	-->
	<!--
		Uncommet to control the number of lines to log a warning message.
		Default: 3. If nonpostive is specified, the full stack traces are
		logged. Notice that # of lines don't include packages starting with
		java, javax or sun. <library-property>
		<name>org.zkoss.util.logging.warningBriefly</name> <value>0</value>
		</library-property>
	-->

	<!--
		Uncommet to control whether the label propeties files are located.
		Default: /WEB-INF/i3-label.properties <library-property>
		<name>org.zkoss.util.label.web.location</name>
		<value>/WEB-INF/i3-label.properties</value> </library-property>
	-->
	<!--
		Uncommet to control the encoding of the labe properties files Default:
		UTF-8 <library-property> <name>org.zkoss.util.label.web.charset</name>
		<value>UTF-8</value> </library-property>
	-->

	<!--
		Uncomment it if you prefer to keep the desktops when an user browses
		to another URL or reloads the page. <client-config>
		<keep-across-visits>true</keep-across-visits> </client-config>
	-->

	<!--
		Configure the Hibernate SessionFactory Lifecycle. <listener>
		<description>Hibernate SessionFactory Lifecycle</description>
		<listener-class>org.zkoss.zkplus.hibernate.HibernateSessionFactoryListener</listener-class>
		</listener>
	-->

	<!--
		Configure the Hibernate configuration file name if not
		"hibernate.cfg.xml" <preference> <name>HibernateUtil.config</name>
		<value></value> </preference>
	-->

	<!--
		Configure the Hibernate "Open Session In View" Session Lifecycle
		<listener> <description>Hibernate "Open Session In View" Session
		Lifecycle</description>
		<listener-class>org.zkoss.zkplus.hibernate.OpenSessionInViewListener</listener-class>
		</listener>
	-->

	<!--
		Hibernate thread session context handler <listener>
		<description>Hibernate thread session context handler</description>
		<listener-class>
		org.zkoss.zkplus.hibernate.HibernateSessionContextListener
		</listener-class> </listener>
	-->
</zk>
 

 

 

 

 

6, 演示Hello World ,创建一个zul首页

 

 

  • *.zul是zk页面的默认后缀,此类页面使用xml语法,但是eclipse默认不支持*.zul扩展的文件,所以无法表示*.zul是一个xml语法的文件,继而不会高亮显示*.zul中xml格式的元素、属性等,

 

 

 

  • 如果让eclipse识别*.zul是xml格式文件呢:Window Menu -->Preferences -->Generals --> Content Type -->Text --> xml --> 点击add按钮 -->输入*.zul -->Ok      这样*.zul扩展的文件eclipse会识别其为xml文件格式

 

 

下面在/WEB-INF/content/上右键 New file      > 选择 file >输入index.zul  --> ok

 

 

在index.zul文件贴入如下代码

 

 

 

 

<?xml version="1.0" encoding="utf-8"?>
<?page title="zk5开发" id="indexPage"?>
<?link rel="shortcut icon" type="image/x-icon" href="favicon.ico"?>
<window id="indexWin" xmlns:h="http://www.w3.org/1999/xhtml"
	xmlns:n="http://www.zkoss.org/2005/zk/native" xmlns="http://www.zkoss.org/2005/zul"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd"
	xmlns:w="http://www.zkoss.org/2005/zk/client">
    Hello  world!
</window>
 

 

zk xml 命名空间及其作用:

 

http://www.w3.org/1999/xhtml  为zk定义的xhtml组件集

 

http://www.zkoss.org/2005/zk/native 为本地代码,即静态html代码,zk框架不解析,直接输出

 

http://www.zkoss.org/2005/zul        zk标准组件集

 

http://www.zkoss.org/2005/zk/client  zk客户端编程,用于监听客户端事件 详解见

 

 

 

 

 

 

7,项目的部署

 

     (1)右键 WebContent  --> Properties -->Resources -->复制Location --> E:\workspaces\dev_eclipse\zk5\WebContent

 

    (2)在D:\Tomcat6.0\conf\Catalina\localhost文件夹内创建,文件zk5.xml,输入如下内容,

<?xml version="1.0" encoding="utf-8"?>
<Context docBase="E:\workspaces\dev_eclipse\zk5\WebContent" path="/zk5" reloadable="true"/>

 

  其中docBase为1中复制的内容,path可写可不写,虚拟目录由xml文件zk5.xml的文件名决定

 

 

    (3)点击Eclipse工具栏的Tomcat图标,启动tomcat,效果如下图

 

 

更多 demo演示

 

 

四,总结

 

本文主要介绍eclipse的使用及zk环境的搭配,其中一些细节是开发中遇到的问题,以及解决方法。

 

后续会一点点介绍【ZK开发】中的一些技术的使用及原理

 

下一篇 《【ZK开发】用户登录》 待续....

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3
0
分享到:
评论

相关推荐

    利用myeclipse插件构建zk开发环境

    通过在MyEclipse中安装和配置相应的zk插件,开发者可以便捷地搭建zk开发环境,进行zk应用的开发和调试。 【标签】:eclipse(MyEclipse是Eclipse的一个商业版本)、zk(ZooKeeper)、插件 【详细知识点】: 1. **...

    zk入门.web框架

    **二、ZK开发环境搭建** ZK的开发环境主要涉及JAR包的导入和web.xml的配置。首先,需要将ZK的相关JAR包导入到项目的类路径中。然后,在web.xml中添加ZK的Servlet配置,以便服务器能够识别ZK的应用。 **三、常用...

    ssh 手动搭建更Happy , 集成jar包 , 详解PPT

    【SSH手动搭建与集成Jar包详解】 ...以上就是关于SSH手动搭建、集成jar包以及ZK开发环境搭建和常用功能的详细解释。通过深入理解这些概念和技术,开发者能够更加熟练地运用SSH和ZK进行Web应用开发。

    spring+zk+dubbo搭建环境

    本文将详细解析如何利用这三个组件搭建一个基础的服务治理环境。 首先,让我们了解一下这三个技术的核心概念: 1. **Spring**:Spring 是一个开源的Java企业级应用框架,它提供了一个全面的编程和配置模型,简化了...

    Nut开发环境搭建.

    ### Nut开发环境搭建详解 #### 一、安装与配置步骤概览 本文旨在详细解析《Nut开发环境搭建》中提及的虚拟机环境下Hadoop、Zookeeper及HBase的开发环境搭建流程,涵盖从虚拟机安装到各组件配置的全过程。 #### 二...

    ajax框架 zk开发手册

    - **环境搭建**:首先,需要在项目中引入ZK的相关依赖库,例如通过Maven或Gradle管理。 - **创建ZUL文件**:使用ZUL文件定义用户界面,ZUL文件包含了各种组件以及它们的属性和事件处理。 - **编写Java控制器**:...

    ZK开发教程ZK开发教程

    ### ZK开发教程知识点概述 #### 一、ZK简介及环境搭建 - **ZK**:是一款基于Java的企业级Web应用开发框架,它提供了一种简单高效的方式来创建丰富的交互式用户界面。与传统的Web开发相比,ZK更加注重于简化开发流程...

    zk+kafka环境搭建1

    在进行Kafka环境搭建时,首先需要确保我们的系统已经配备了必要的依赖,尤其是Java开发环境。在这个案例中,我们使用的是Java 8的特定版本,即jdk-8u25-linux-x64。下面是详细的Java环境安装步骤: 1. **下载与解压...

    codis测试环境搭建

    《搭建 Codis 测试环境详解》 Codis 是一款针对 Redis 扩展性的解决方案,它提供了分布式 Redis 服务,使得用户在使用时如同与单机 Redis 交互,但背后却可以实现水平扩展和高可用性。本文将详细介绍如何在测试环境...

    MyEclipse 6.0下zk开发文档

    在JDK6.0、Eclipse3.3和MyEclipse6.0M环境下,可以搭建ZK 2.4.1的开发环境。ZK开发包通常包含ZK的开发库、依赖库、扩展库以及源码。例如,开发包下的`dist`目录会包含如`lib`子目录,其中包含如`zcommon.jar`等核心...

    ZK 开发手顺

    ZK环境搭建 2.1 **安装环境前,需要下载的东西** 首先,你需要下载ZK的发行版,这通常包括ZK服务器和相关的开发工具。同时,确保你的系统已经安装了Java开发环境(JDK)和集成开发环境(如Eclipse)。 2.2 **...

    zk开发手册 初学着跟着看看

    【标题】"ZK开发手册 初学者跟着看看" 提示我们这是一份针对初学者的Zookeeper(简称ZK)开发指南。Zookeeper是一个分布式协调服务,常用于管理大型分布式系统中的配置信息、命名服务、集群同步和分布式锁等功能。 ...

Global site tag (gtag.js) - Google Analytics