zoukankan      html  css  js  c++  java
  • DWR Annotations

    DWR   Annotations

    DWR 标注是用来代替 dwr.xml 或者与其一同工作的。

    1.初始配置

     1 <servlet>
     2     <description>DWR controller servlet</description>
     3     <servlet-name>DWR controller servlet</servlet-name>
     4     <servlet-class>
     5         org.directwebremoting.servlet.DwrServlet
     6     </servlet-class>
     7     <init-param>
     8         <param-name>classes</param-name>
     9         <param-value>
    10             com.example.RemoteFunctions, com.example.RemoteBean
    11         </param-value>
    12     </init-param>
    13 </servlet>    

      servlet 参数 classes 定义的时可以标注的类的全名,这些名字用逗号分割。

    2.远程访问类

      要使一个简单的 class 可以成为远程访问类,你需要使用@Create 和@RemoteMethod 标注。

    1 @Create
    2 public class RemoteFunctions {
    3     @RemoteMethod
    4     public int calculateFoo() {
    5         return 42;
    6     }
    7 }

      没有被@RemoteMethod 标注的方法不能被远程访问。

      要在 Javascript 使用不同于类型的名字,使用@Create 标注的 name 属性。

    @Create(name = "Functions")
    public class RemoteFunctions { 
    }

    3.对象转换

      要使一个简单的 bean 类可以被远程访问,  使用@Convert 和@RemoteProperty 标注:

     1 @Convert
     2 public class Foo {
     3 
     4     @RemoteProperty
     5     private int foo;
     6 
     7     public int getFoo() {
     8         return foo;
     9     }
    10 
    11     @RemoteProperty
    12     public int getBar() {
    13         return foo * 42;
    14     }
    15 }

      要使用复杂的转换器,使用@Convert 标注的  converter  属性。

    错误和异常处理

      

    走在一起是缘分,在一起走是幸福; 在一起走是缘分,走在一起是幸福
  • 相关阅读:
    IOC理论推导
    spring leile
    缓存
    动态SQL
    canvas小球运动
    jdk1.7后字符串的总结
    用ssm框架简单创建一个增删改查案列
    京东物流居家品类各区域联系人
    京东网址收藏
    京东自营申请新品打标方法
  • 原文地址:https://www.cnblogs.com/tarena/p/3684146.html
Copyright © 2011-2022 走看看