码迷,mamicode.com
首页 > 其他好文 > 详细

@RemoteProxy()注释 与@File注释的使用

时间:2017-06-07 12:30:57      阅读:436      评论:0      收藏:0      [点我收藏+]

标签:nbsp   jsp   not   web.xml   framework   attribute   ext   sources   default   

@RemoteProxy()注释

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()
    {
    }
}

 

@RemoteProxy()注释 与@File注释的使用

标签:nbsp   jsp   not   web.xml   framework   attribute   ext   sources   default   

原文地址:http://www.cnblogs.com/hpj1038361347/p/6956011.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!