`

DWR配置、and整合在spring!

    博客分类:
  • DWR
阅读更多
    <!-- 
    <create creator="spring" javascript="dwrShowStyle" scope="page">
      <param name="class" value="com.fids.ssh.dao.showstyleDao"/>
      <include method="showStyleData"/>
    </create>
       -->
      
    <!-- convert标签是为了javascript可以调用有javabean参数的java方法 
    <convert converter="bean" match="com.fids.ssh.entity.Showstyle">
    </convert>
    -->

 上面是DWR.xml的配置,用于前台js来调用Service实现类

 

或者DWR整合spring,配置在spring中

<?xml version="1.0" encoding="UTF-8"?>
<!--
	配置系统基础环境
	showstyle模块
	author:cheney
 -->
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    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-2.0.xsd
     http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd">

                
	<bean id="showStyleDao" class="com.fids.ssh.showstyle.ShowStyleDaoImpl" parent="daoBase">
		<property name="hibernateTemplate" ref="hibernateTemplate"></property>
	</bean>
	<bean id="showStyleService" class="com.fids.ssh.showstyle.ShowStyleServiceImpl">
	    <property name="showStyleDao" ref="showStyleDao"></property>
	</bean>
	<bean id="showStyle" class="com.fids.ssh.showstyle.ShowStyleAction" scope="prototype" parent="actionBase">
		<property name="showStyleService" ref="showStyleService"></property>
	</bean>
	
   <!-- DWR配置 -->
    <dwr:configuration>
    	<!-- convert标签是为了javascript可以调用有javabean参数的java方法 -->
    	<dwr:convert type="bean" class="com.fids.ssh.entity.Showstyle"></dwr:convert>
    </dwr:configuration>
    <dwr:controller id="dwrController" debug="true" />
  
<!-- StyleDwrController 这个类算是个DWR控制类-->
    <bean id="ajax" class="com.fids.ssh.dwr.StyleDwrController">
        <dwr:remote javascript="dwrShowStyle">
            <dwr:include method="showStyleData" />
            <dwr:include method="addStyle"/>
        </dwr:remote>
        <property name="showStyleService" ref="showStyleService"></property>
    </bean>
	
	
</beans>

 

package com.fids.ssh.dwr;

import java.util.List;

import com.fids.ssh.entity.Showstyle;
import com.fids.ssh.showstyle.ShowStyleService;

public class StyleDwrController {

	private ShowStyleService showStyleService;
	
	/**
	 * 
	 * 读取样式信息
	 */
	public Showstyle showStyleData(String type){
		//........
                               return null;
	}
	
	public boolean addStyle(String htmlCode){
		//........		
                            return bflag;
	}

	public ShowStyleService getShowStyleService() {
		return showStyleService;
	}

	public void setShowStyleService(ShowStyleService showStyleService) {
		this.showStyleService = showStyleService;
	}
}

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics