다둥이개발자
31
2015-11-05 10:26:53
2
3690

Spring + ZK Framework 연동 및 환경설정 방법


목차

  1. ZK Framework 소개
  2. Spring + ZK Framework 연동 및 환경설정 방법
  3. ZK Framework 프로젝트 적용기

Spring + ZK Framework 연동 및 환경설정 방법

테스트 환경은 Java1.6 + Spring3.1.2 + ZK Framework  6.0.2로 구성하였습니다.

먼저 이클립스(Juno)에서 작업하기 위해 ZK Studio를 설치한다

 -  [Help] -> [Install New Software] > http://studio.zkoss.org/resource/plugins/eclipse_4_2

※ 이클립스(Juno) 하위 버전일 경우 아래 주소를 참조 하면된다.

    http://www.zkoss.org/download/zkstudio


1) pom.xml 

ZK 라이브러리 추가한다.

<!-- Properties -->
<properties>
   <zk.version>6.0.2</zk.version>
</properties>

<!-- ZK dependency -->
<dependency>
	<groupId>org.zkoss.zk</groupId>
	<artifactId>zkbind</artifactId>
	<version>${zk.version}</version>
</dependency>
<dependency>
	<groupId>org.zkoss.zk</groupId>
	<artifactId>zul</artifactId>
	<version>${zk.version}</version>
</dependency>
<dependency>
	<groupId>org.zkoss.zk</groupId>
	<artifactId>zkplus</artifactId>
	<version>${zk.version}</version>
</dependency>
<dependency>
	<groupId>org.zkoss.zk</groupId>
	<artifactId>zhtml</artifactId>
	<version>${zk.version}</version>
</dependency>

<!-- Spring MVC -->
<dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-webmvc</artifactId>
	<version>3.1.2.RELEASE</version>
</dependency>


2) web.xml 

스프링MVC는 DispatcherServlet가 해당 어플리케이션으로 들어오는 요청을 모두 핸들링 하지만 ZK Framework는 DHtmlLayoutServlet에서 핸들링한다.

<!-- 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>
	<init-param>
		<param-name>update-uri</param-name>
		<param-value>/zkau</param-value>
	</init-param>
	<load-on-startup>1</load-on-startup>
</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>
	<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-mapping>
	<servlet-name>auEngine</servlet-name>
	<url-pattern>/zkau/*</url-pattern>
</servlet-mapping>


3) spring-servlet.xml

ZK Framework View단의 파일 확장자는 *.zul파일을 사용하기에

ViewResolver의 suffix 값을 제거한다.

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
	<property name="prefix" value="/WEB-INF/" />
	<property name="suffix" value="" />
</bean>


4) TestController.java

@RequestMapping(value = {"/zkTest"}, method = RequestMethod.GET)
public String index() {
   return "zul/test.zul";
}


5) test.zul

<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
<window title="제목" border="normal">
테스트 페이지 입니다.
</window>
</zk>


6) 실행화면


                                                      Published by JongHwan Lee

                                                          www.devnect.com 

0
0
  • 댓글 2

  • narise
    2k
    2015-11-05 21:16:38

    스프링+dwr 보다 나은점이 있습니까?


    0
  • javaguide
    233
    2015-11-11 15:49:30

    뭐때문에 이걸 하셨는지 부터...

    1
  • 로그인을 하시면 댓글을 등록할 수 있습니다.