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

dwr问题,搞了两天都搞不出来,跪求各位大牛打一下。。。。。。
dwr.xml

<?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/dwr30.dtd">
<dwr>
<allow>
<create javascript="maildao" creator="new">
<param name="class" value="com.dbs.mail.dao.impl.MailDaoImpl"></param>
</create>

</allow>
</dwr>


web.xml
 <display-name>DWR (Direct Web Remoting)</display-name>
  <description>A Simple Demo DWR</description>
  
  <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>

MailDaoImpl中的deleteMessage方法
public boolean deleteMessage(int id) {
try {
session.beginTransaction();
Mail m=(Mail) session.get(Mail.class, id);
System.out.println("++++++++++++++++++++deleteMessage+++++++++++++++++++++++");
m.setDelState(1);
session.getTransaction().commit();
return true;
} catch (HibernateException e) {
e.printStackTrace();
return false;
}finally{
if(session!=null){

session.close();
}
}
}

javascript;
<script type="text/javascript">
function deleteMail(id,a){
/*  alert(id); */ //在这里id是可以取到的
alset(a);
maildao.deleteMessage(id,function(result){
alert("ssssssssssssssssss");
if(result){
alert("删除成功");
var tr=a.parentNode.parentNode;
tr.parentNode.removeChild(tr);
}else{
alert("删除失败");

}

});
}
</script>



jsp代码(部分省略)
<script src='/dwr/interface/maildao.js'></script>
<script src='/dwr/util.js'></script>
<script src='/dwr/engine.js'></script>

  </head>
  
  <body>
   <s:property value="msg"/><br>
   <s:include value="top.jsp"></s:include>
     <hr color="red">
     <table border="1" width="80%" align="center">
      <tr>
      <th>标题</th><th>内容</th><th>操作</th>
      </tr>
    <s:iterator value="#session.user.sendMails" var="mails">
    <tr>
    <td>
    <s:property value="#mail