当前位置: 代码迷 >> Web前端 >> spring 2.0 调整 DWR2.0
  详细解决方案

spring 2.0 调整 DWR2.0

热度:452   发布时间:2012-10-09 10:21:45.0
spring 2.0 整合 DWR2.0

spring2.5整合dwr2.0:

1方法,从网上抄来的:

? (1)applicationContext.xml:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
		 xmlns:dwr ="http://www.directwebremoting.org/schema/spring-dwr" 
	     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	     xmlns:aop="http://www.springframework.org/schema/aop"
	     xmlns:tx="http://www.springframework.org/schema/tx"
	     xsi:schemaLocation="http://www.springframework.org/schema/beans
	       http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
           http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd">

	<dwr:configuration>
		<!-- 在 dwr:configuration 下配置多个dwr:convert-->
		<dwr:convert type="bean" class="com.DemoBean">
			<dwr:exclude method="getList, checkUser"/>
		</dwr:convert>
	</dwr:configuration>
	
	<bean id="DWRExample" class="com.DWRExample">
		<dwr:remote javascript="DWRExample"></dwr:remote>
	</bean>

</beans>

? (2)业务逻辑类:

?

public class DWRExample implements Serializable {
	
	public List getList()
	{
		
		List list=new ArrayList();
		DemoBean db=null;
		for(int i=0;i<5;i++)
		{
			db=new DemoBean();
			db.setAge(22+i);
			db.setName("ddh"+i);		
			list.add(db);
		}
			
		
		return list;
		
	}
	
	public boolean checkUser(String name)
	{
		if("xy".equals(name))
		{
			return true;
		}else
		{
			return false;
			
		}
	}
}

?? (3)业务需要的实体类:

???

public class DemoBean implements Serializable {

	
	private String name;
	private int age;
	getter & setter..
	
}

?web.xml:

?

 <servlet>
    <servlet-name>dwrInvoker</servlet-name>
    <servlet-class>org.directwebremoting.spring.DwrSpringServlet</servlet-class>
    <init-param>
      <param-name>debug</param-name>
      <param-value>true</param-value>
    </init-param>
      
      <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>dwrInvoker</servlet-name>
    <url-pattern>/dwr/*</url-pattern>
  </servlet-mapping>

?来源:http://www.blogjava.net/max/archive/2007/01/31/97009.html

?

?spring2.5 & dwr2.0http://blog.csdn.net/WalkingWithJava/archive/2008/07/23/2698323.aspx

  相关解决方案