alert(exception.message);
}
function exceptionHandler(exceptionString, exception){
//alert("lai excption2222!");
alert(exception.message);
}
Name:
Reply:
和spring集成方法:
编写远程访问类
package com.dwr3.annotation;
import org.directwebremoting.annotations.RemoteMethod;
import org.directwebremoting.annotations.RemoteProxy;
import org.directwebremoting.spring.SpringCreator;
@RemoteProxy(creator=SpringCreator.class)
public class SayHello {
@RemoteMethod()
public String sayHello(){
return "say hello";
}
@RemoteMethod
public String sayHello(String name){
return name+" say hello";
}
}
2.配置Web.xml文件
< xml version="1.0" encoding="UTF-8" >
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
3.配置Spring配置文件(applicationContext.xml)
< xml version="1.0" encoding="UTF-8" >
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-3.0.xsd
http://www.directwebremoting.org/schema/spring-dwr
http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd">
4.编写测试代码
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<script type='text/java script' src='/MyBatis/dwr/interface/sayHello.js'>
<script type='text/java script' src='/MyBatis/dwr/engine.js'>
<script type="text/java script">
function SayHelloTest(){
var str = document.getElementById("name").value;
sayHello.sayHello(str,function(value){
alert(value);
});
}