DWR2.0+Spring2.0 : DWR2.0 与 Spring2.0的整合

本文详细介绍如何将DWR2.0与Spring2.0进行整合,包括web.xml配置、Spring配置文件中加入DWR支持、声明<dwr:configuration>元素及creator和converter的编写。

     DWR2.0+Spring2.0 : DWR2.0 与 Spring2.0的整合

   本文重点介绍DWR2.0与Spring2.0的整合,在阅读本文之前,假设读者已经了解了 DWR 与 spring的基本原理。

   1,web.xml 中 对Spring的配置如下:

 

<context-param>
	<param-name>contextConfigLocation</param-name>
	<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
	<listener-class>
		org.springframework.web.context.ContextLoaderListener
	</listener-class>
</listener>	
<filter>
	<filter-name>requestContextFilter</filter-name>
	<filter-class>
		org.springframework.web.filter.RequestContextFilter
	</filter-class>
</filter>
<filter-mapping>
	<filter-name>requestContextFilter</filter-name>
	<url-pattern>/*</url-pattern>
</filter-mapping>
 

 

2,web.xml 中 对DWR的配置如下:


<servlet>
	<servlet-name>dwr-invoker</servlet-name>
	<servlet-class>
		org.directwebremoting.spring.DwrSpringServlet
	</servlet-class>
	<init-param>
		<param-name>debug</param-name>
		<param-value>true</param-value>
	</init-param>
	<init-param>
		<param-name>crossDomainSessionSecurity</param-name>
		<param-value>true</param-value>
	</init-param>
	<init-param>
		<param-name>allowScriptTagRemoting</param-name>
		<param-value>true</param-value>
	</init-param>
</servlet>

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

3,Spring配置文件中加入DWR支持

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:aop="http://www.springframework.org/schema/aop"
	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.springframework.org/schema/aop 
    	 http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
     	http://www.directwebremoting.org/schema/spring-dwr
    	 http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd">
 

4,声明<dwr:configuration>元素

  注意:必须在Spring配置文件中声明<dwr:configuration>元素(作为<beans>的子元素)。

 

<dwr:configuration>
     ......
</dwr:configuration>
 

   也可以把这个元素置空。

 

<dwr:configuration/>
 

5,creator 和 converter 的 编写

   (1)  可以直接将creator和converter写到<dwr:configuration>元素里,如下所示:


<dwr:configuration>
	 <dwr:create javascript="JHello" type="spring" scope = "session">
	    	<dwr:param name="beanName" value = "hello"/>
		<dwr:include method = "Hello"/>
	 </dwr:create>
	<dwr:convert type="bean"
		class="org.test.People">
		<dwr:include method="name" />
		<dwr:include method="age" />
	</dwr:convert>
</dwr:configuration>
 <bean id="hello" class="org.test.Hello"> </bean>
 

  (2)将creator和converter写到<bean>元素里,下面的代码与(1)是等价的,但与Spring结合得更加优美


 <bean id="hello" class="org.test.Hello"
  	 scope="session">
  	<dwr:remote javascript="JHello">
   		<dwr:include method="hello" />
		<dwr:convert type="bean"
		                       class="org.test.People">
		              <dwr:include method="name" />
		              <dwr:include method="age" />
                                </dwr:convert>
 	</dwr:remote>
 </bean>
 

 spring与dwr整合的的官方资料:http://directwebremoting.org/dwr/server/spring



单向双向V2G 环境下分布式电源电动汽车充电站联合配置方法(Matlab代码实现)内容概要:本文介绍了在单向和双向V2G(Vehicle-to-Grid)环境下,分布式电源电动汽车充电站的联合配置方法,并提供了基于Matlab的代码实现。研究涵盖电力系统优化、可再生能源接入、电动汽车充放电调度、储能配置及微电网经济调度等多个关键技术领域,重点探讨了在不同电价机制和需求响应策略下,如何通过智能优化算法实现充电站分布式电源的协同规划运行优化。文中还展示了多种应用场景,如有序充电调度、鲁棒优化模型、多目标优化算法(如NSGA-II、粒子群算法)在电力系统中的实际应用,体现了较强的工程实践价值和技术综合性。; 适合人群:具备电力系统、新能源、智能优化算法等相关背景的科研人员、研究生及从事能源系统规划优化的工程技术人员;熟悉Matlab/Simulink仿真工具者更佳。; 使用场景及目标:①用于科研项目中关于电动汽车分布式电源协同配置的模型构建仿真验证;②支持毕业论文、期刊投稿中的案例分析算法对比;③指导实际电力系统中充电站布局能源调度的优化设计。; 阅读建议:建议结合文中提供的Matlab代码具体案例进行同步实践,重点关注优化模型的数学建模过程算法实现细节,同时可参考文末网盘资源获取完整代码数据集以提升学习效率。
【电动车】【超级棒】基于蒙特卡洛模拟法的电动汽车充电负荷研究(Matlab代码实现)内容概要:本文围绕基于蒙特卡洛模拟法的电动汽车充电负荷研究展开,利用Matlab代码实现对不同类型电动汽车(如常规充电、快速充电、换电模式)在不同场景下的充电负荷进行建模仿真。通过蒙特卡洛方法模拟大量电动汽车的充电行为,结合用户出行规律、充电时间、电量需求等随机因素,分析电动汽车规模化接入电网后对电力系统负荷的影响,并探讨分时电价策略对充电负荷的引导作用,进而优化电网运行。研究涵盖充电负荷的空间分布特性、时间分布特征及对电网峰谷差的影响,旨在为电力系统规划和电动汽车有序充电管理提供理论支持和技术工具。; 适合人群:具备一定电力系统、交通工程或新能源汽车背景的研究生、科研人员及从事智能电网、电动汽车相关领域的工程技术人员。; 使用场景及目标:①用于研究大规模电动汽车接入对配电网负荷曲线的影响;②支撑分时电价、需求响应等政策制定优化;③为充电站规划、电网调度、储能配置等提供数据支持和仿真平台;④适用于学术研究、课题复现及工程项目前期分析。; 阅读建议:建议读者结合文中提供的Matlab代码进行实践操作,重点关注蒙特卡洛模拟的参数设置、充电行为的概率建模过程,并尝试调整输入变量以观察负荷变化趋势,加深对电动汽车充电负荷不确定性和聚合效应的理解。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值