관리 메뉴

IT.FARMER

DWR reverse Ajax / Spring MVC -1 본문

JAVA/comet

DWR reverse Ajax / Spring MVC -1

아이티.파머 2011. 9. 1. 14:47
반응형
실시간..  DWR, reverse Ajax 특히 Spring MVC 이놈 버전 때문에 애좀 먹었네,

1.  web.xml

<?xml version="1.0" encoding="utf-8"?>
<web-app 
xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">

<!-- DWR servlet -->
<servlet>
<servlet-name>contextLoaderDWR</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- DWR servlet mapping-->
<servlet-mapping>
<servlet-name>contextLoaderDWR</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
</web-app> 

2. dwr-servlet.xml 
 <?xml version="1.0" encoding="UTF-8"?>
<!-- Application context Default Action definition  -->
<beans 
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.directwebremoting.org/schema/spring-dwr
  http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd">
<!-- 
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
-->
<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
<!-- debug true /dwr/index.html 확인가능 -->
<dwr:controller id="dwrController" debug="true">
<dwr:config-param name="scriptCompressed" value="true"/>
<dwr:config-param name="activeReverseAjaxEnabled" value="true"/>
<dwr:config-param name="org.directwebremoting.extend.ServerLoadMonitor" value="org.directwebremoting.impl.PollingServerLoadMonitor"/>
<dwr:config-param name="disconnectedTime" value="1000"/><!-- 0.1초  지정하지 않으면 default 5초 (50000) -->
<dwr:config-param name="allowScriptTagRemoting" value="false"/>
</dwr:controller>
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="alwaysUseFullPath" value="true"></property>
<property name="mappings">
<props>
<prop key="/dwr/engine.js">dwrController</prop>
<prop key="/dwr/util.js">dwrController</prop>
<prop key="/dwr/interface/**">dwrController</prop>
<prop key="/dwr/**/*">dwrController</prop>
</props>
         </property>
</bean>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
<!-- JSON 방식으로 사용할 데이터 모델객체를 설정하는 부분 -->
<dwr:configuration>
<dwr:convert type="bean" class="com.dongbu.farm.system.dwr.ChatVO"></dwr:convert>
</dwr:configuration>
<bean id="hello" class="com.dongbu.farm.system.dwr.Hello">
<dwr:remote javascript="hello">
<dwr:include method="say"/>
</dwr:remote>
</bean>
<bean id="chatDWR" class="com.dongbu.farm.system.dwr.ChatDWR">
<dwr:remote javascript="chat">
<dwr:include method="notify"/>
</dwr:remote>
</bean>
</beans>


반응형

'JAVA > comet' 카테고리의 다른 글

DWR reverse Ajax / Spring MVC -3  (0) 2011.09.01
DWR reverse Ajax / Spring MVC -2  (0) 2011.09.01
dwr Spting 환경설정  (0) 2011.08.31
Ajax real time (Reverse AJAX)  (0) 2011.08.30
수정요망 원하는 시간에 리로드  (0) 2011.06.17