1.创建一个Web Project项目,导入dwr.jar包。
- <?xmlversion="1.0"encoding="UTF-8"?>
- <web-appversion="2.5"
- xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
- <!--dwr核心servlet-->
- <listener>
- <listener-class>org.directwebremoting.servlet.DwrListener</listener-class>
- </listener>
- <servlet>
- <!--dwr核心servelt实现类-->
- <servlet-name>dwr</servlet-name>
- <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
- <!--设置dwr可调式-->
- <init-param>
- <param-name>debug</param-name>
- <param-value>true</param-value>
- </init-param>
- <!--设置ajax的反向技术-->
- <init-param>
- <param-name>activeReverseAjaxEnabled</param-name>
- <param-value>true</param-value>
- </init-param>
- <param-name>initApplicationScopeCreatorsAtStartip</param-name>
- <!--长连接时保持时间-->
- <param-name>maxWaitAfterWrite</param-name>
- <param-value>60</param-value>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <url-pattern>/dwr/*</url-pattern>
- </servlet-mapping>
- <welcome-file-list>
- <welcome-file>index.jsp</welcome-file>
- </welcome-file-list>
- </web-app>
3.创建一个SendingMessage.java类
copy