日期:2014-05-17  浏览次数:20767 次

DWR在页面上调用不了方法(在线等!)
写了一个dwr验证用户名是否存在,在dwr测试页面里,方法成功通过,但在页面上,没有调用dwr那个类
(配置文件都没有错误,否侧在dwr测试页是无法调用到那个方法的
以下是jsp页面的全部代码

<script type="text/javascript" src="dwr/util.js"></script>
<script type="text/javascript" src="dwr/engine.js"></script>
<script type="text/javascript" src="dwr/interface/Test.js"></script>
<script type="text/javascript">
function regUserChked()
{
var username =${"account"}.value;
Test.valeng(username,showData);
}
function showData(data)
{
if(data){  
  DWRUtil.setValue("userMsg","该用户名已经被注册,请更换您的用户名!");  
  }else{  
  DWRUtil.setValue("userMsg","恭喜您,该用户名尚未被注册!");  
  }
}
  </script>
</head>

<body>
<form action="ad.do?method=add_acount" method="post">
<table width="404" height="118" border="1">
<tr>
<td height="20">
用户名:
<input type="text" name="account" id="accounts"
onblur="regUserChked()" />
<div id="userMsg"></div>
</td>
<td>
2
</td>
</tr>
<tr>
<td height="24">
密码:
<input type="password" name="passwords">
</td>
<td>
4
</td>
</tr>
<tr>
<td width="206">
<input type="submit" value="注册" id="submit">
</td>
<td width="182">
<input type="reset" name="ru" value="重置">
</td>
</tr>
</table>
</form>
</body>
</html>

dwr的配置文件
<?xml version="1.0" encoding="UTF-8"?>  
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN" "http://www.getahead.ltd.uk/dwr/dwr10.dtd">  
<dwr>  
  <allow>  
  <create creator="spring" javascript="Test">  
  <param name="beanName" value="usingdwr" />  
  </create>  
  </allow>  
</dwr>  

Spring的配置文件
<!-- dwr配置 -->
<bean id="usingdwr" class="dwr.TestDwr">
<property name="dao">
<ref bean="dao" />
</property>
</bean>


------解决方案--------------------
var username =${"account"}.value; 
-> $("account")
------解决方案--------------------
探讨
var username =${"account"}.value;
-> $("account")