日期:2014-05-16  浏览次数:20748 次

刚学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="new" javascript="ZipcodeManager"
        class="com.zipcode.ZipcodeManager">
    <include method="getZipcode"/>
</create>
<convert converter="bean" match="com.zipcode.Zipcode">
    <param name="include" value="city,state,zipcode"/>
</convert>
    </allow>
</dwr>

web.xml
<?xml version="1.0" encoding="UTF-8"?> 

<web-app id="WebApp_ID" version="2.4"  
xmlns="http://java.sun.com/xml/ns/j2ee"  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
xsi:schemaLocation= 
"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 

  <display-name>  ajaxDWR</display-name> 
  <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> 
</web-app>

主页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>DWR TEST</title>

<script type="text/javascript" src="/dwr/interface/ZipcodeManager.js"></script>
<script type="text/javascript" src="/dwr/engine.js"></script>
<script type="text/javascript" src="/dwr/util.js"></script>
<script type="text/javascript" src="zipcode.js"></script>

</head>
<body>
<h1>Ajax Zip Codes Whit DWR</h1>
<table height="50%" border="0" cellspacing="5">
  <tr>
    <td>Zip Code: </td>
    <td><input type="text" name="zipcode" id="zipcode"   onblur="retrieveData()" /></td>
  </tr>
  <tr>
    <td>City:</td>
    <td><input name="city" type="text" id="city" /></td>
  </tr>
  <tr>
    <td>State:</td>
    <td><input type="