springMVC集成DWR:
参考:
http://www.iteye.com/topic/209008
http://stevenfeng.iteye.com/blog/816010

集成DWR之前,先做Spring MVC和Hibernate整合的例子:http://panyongzheng.iteye.com/blog/1228193
然后在这个基础之上整合DWR:

1.到http://directwebremoting.org/dwr/downloads/index.html下载最新的dwr.jar,这里是使用dwr3.然后放到WEB-INF/lib下面去。
同时找到commons-logging.jar,DwrSpringAnnotations.jar这两个包,并放到lib下面去,去掉没必要的包:去掉cglib-2.2.jar,
保留com.springsource.net.sf.cglib-2.2.0.jar.

下面的的代码是js->controller->dwr–>service–>dao…..

2.配置web.xml

这个是不能少的。

3.修改springhibernate-servlet.xml:

3.建立webControllerContext.xml

假如不用<dwr:convert class=”com.pojo.User” type=”bean” />对转换对象进行扫描,
那就用<dwr:annotation-scan base-package=”com.asl.cityu.entity” scanDataTransferObject=”true”/>进行一次扫描,必需的放在<dwr:configuration/>外面。

把xml头部定义
http://www.directwebremoting.org/schema/spring-dwr
http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd
改成:
http://www.directwebremoting.org/schema/spring-dwr
http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd

4.修改applicationContext.xml

要是不用<property name=”annotatedClasses”>
<list>
<value>com.pojo.User</value>
</list>
</property>
的话  就要hibernate自己扫描自己的东西
<bean id=”sessionFactory” class=”org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean”
p:dataSource-ref=”dataSource”
p:packagesToScan=”com.asl.jwaf.sysconfig.model”>
……
</bean>

5.建立WebRoot/pages/ajax/ajax-add-page.jsp

6.建立WebRoot/pages/ajax/ajax_add_page.js文件:

 

7.建立controller
Hello.java
—————————————