dwr3.0与Spring mvc的全注解集成方法( @RemoteMethod)(@RemoteProxy)
来源:互联网 发布:网络教育学士学位考试 编辑:程序博客网 时间:2024/06/04 19:10
dwr3.0可以通过全注解的方式,极大的简化了配置,所有xml配置加在一起不超过20行,而且使用更加简单,bean注入的问题也都解决。配置步骤如下:
web.xml的配置文件中,在默认的DispatcherServlet的mapping里加上dwr
<servlet> <servlet-name>appServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/appServlet/appServlet-context.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>appServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>appServlet</servlet-name> <url-pattern>/dwr/*</url-pattern> </servlet-mapping>
dispatcherServlet的配置文件appServlet-context.xml
<?xml version="1.0" encoding="UTF-8"?><beans:beans xmlns="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd"> <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure --> <!-- Enables the Spring MVC @Controller programming model --> <annotation-driven /> <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory --> <resources mapping="/resources/**" location="/resources/" /> <interceptors> <beans:bean class="com.panguso.op.data.manager.interceptor.LogInterceptor"></beans:bean> </interceptors> <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory --> <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <beans:property name="prefix" value="/WEB-INF/views/" /> <beans:property name="suffix" value=".jsp" /> </beans:bean> <!--<view-controller path="/" view-name="index" /> --> <context:component-scan base-package="com.panguso.op.data.manager" /> <!-- 从这行往下是要添加的 --> <context:annotation-config /> <dwr:configuration /> <dwr:annotation-config /> <dwr:url-mapping /> <dwr:controller id="dwrController" debug="true"> <dwr:config-param name="allowScriptTagRemoting" value="true" /> <dwr:config-param name="crossDomainSessionSecurity" value="false" /> </dwr:controller> <beans:bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"> <beans:property name="order" value="1" /> </beans:bean> <beans:bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"> <beans:property name="order" value="2" /> </beans:bean> <!--添加结束--></beans:beans>
配置完毕,使用的方法和上文类似,注意的是@RemoteProxy标注的远程类一定要加上name属性,不然启动会报错,如:
@Service@RemoteProxy(name = "GeneralContentManagementService")public class GeneralContentManagementService { @RemoteMethod public void aaa() { }}
0 0
- dwr3.0与Spring mvc的全注解集成方法( @RemoteMethod)(@RemoteProxy)
- dwr3.0与Spring mvc的全注解集成方法
- DWR3.0与Spring MVC集成方法
- DWR3与spring集成(不使用springMVC,但使用注解的实例)
- DWR3基于Spring MVC配置Controller的方法
- struts2.2.1+spring 3.0.3+hibernate3.6+dwr3.0全注解整合详解
- struts2.2.1+spring 3.0.3+hibernate3.6+dwr3.0全注解整合详解
- Spring MVC 集成 AOP,自定义注解,在切面获得方法参数,以及自定义注解的参数。
- DWR3+spring mvc实现
- spring mvc 集成 thymeleaf ----注解
- dwr3.0整合spring2.5全注解配置
- Dwr3.0与struts2一起使用的方法步骤详解
- dwr3.0 and 注解
- spring-mvc 注解方法的返回值
- Thymeleaf MVC与Spring的集成
- spring ioc注解与spring mvc注解
- spring MVC的注解
- Spring MVC的注解@
- ACCESS中各查询的功能简介、SQL语法
- MFC解决Static控件背景透明时文本覆盖重影
- 太赫兹成像应用
- 统计正整数中指定数字的个数(4分)
- MenuRecommend智能推荐算法
- dwr3.0与Spring mvc的全注解集成方法( @RemoteMethod)(@RemoteProxy)
- MYSQL主从同步
- Cocos Creator中使用计时器(官方文档摘录)
- 【直播预告】云栖直播:阿里热修复产品HotFix2.0升级详解
- 2 统计用户输入(4分)
- 分析iOS Crash文件:符号化iOS Crash文件的3种方法
- JSch - Java实现的SFTP(文件上传详解篇)
- @Autowired和@Resource的区别是什么?
- 三天打渔两天晒网(4分)(待改,输入1993-2-29或是月份天数大于实际天数如1999年2月30日时无法判定输入错误)