这个是错哪了啊java.lang.NoSuchMethodException: action.StudentsAction.delete()
<td><a href="<%=path%>/students/Students_delete.action?sid=<s:property value="#stu.sid"/>" onclick="javascript: return confirm('真的要删除吗?');">删除</a></td>
StudentsDAOImpl.java
public boolean deleteStudents(String sid) {
// TODO Auto-generated method stub
Transaction tx=null;
//String hql="";
try {
Session session=MyHibernateSessionFactory.getSessionFactory().getCurrentSession();
tx=session.beginTransaction();
Students s=(Students)session.get(Students.class, sid);
session.delete(s);
tx.commit();
return true;
} catch (Exception ex) {
ex.printStackTrace();
tx.commit();
return false;
}finally {
if(tx!=null){
tx=null;
}
}
}
StudentsAction.java
//删除学生动作
public String delete(){
StudentsDAO sdao=new StudentsDAOImpl();
String sid=request.getParameter("sid");
sdao.deleteStudents(sid);//调用删除方法
return "delete_success";
}
Struts.xml
<package name="students" namespace="/students" extends="default">
<action name="*_*" class="action.{1}Action" method="{2}">
<result name="query_success">/students/Students_query_success.jsp</result>
<!--chain相当于服务器内部转换,但后面必须跟方法,如下 -->
<result name="delete_success" type="chain">Students_query</result>
</action>
</package>