web.xml里配置
<!-- DWR配置 --> <servlet> <servlet-name>dwr-invoker</servlet-name> <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class> <init-param> <param-name>debug</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> <!-- /DWR配置 -->
DWR.xml文件
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://getahead.org/dwr/dwr20.dtd">
<dwr>
<allow> <create creator="spring" javascript="City"> <param name="beanName" value="biz"/> <!--<include method="方法名" />--> </create> <convert converter="bean" match="com.xasxt.po.City"> <param name="include" value="id,name"/> </convert> </allow></dwr>
、、、、、、、、、、管用的小例子
City.findCityByShengId(shengId, { callback:function (data) { var shi = document.getElementByIdx_x("shi"); shi.options.length = 0; for (var i = 0; i < data.length; i++) { shi.options[shi.options.length] = new Option(data[i].name, data[i].id); } }, errorHandler:function (msg) { alert(msg); }, timeout:500 });