码迷,mamicode.com
首页 > 其他好文 > 详细

SSH_框架整合3-删除

时间:2016-09-19 01:07:40      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:

一、普通删除

1 完善src中 类:

(1)EmployeeDao.java中: 

技术分享
1 //2 删除
2     public void delete(Integer id){
3         String hql="DELETE FROM Employee e WHERE e.id=?";
4         getSession().createQuery(hql).setInteger(0,id).executeUpdate();
5     }
View Code

(2)EmployeeService.java中:

技术分享
1 //2删除
2     public void delete(Integer id){
3         employeeDao.delete(id);
4     }
View Code

(3)EmployeeAction.java中:

技术分享
1 //2 删除
2     private Integer id;
3     public void setId(Integer id) {
4         this.id = id;
5     }
6     public String delete(){
7         employeeService.delete(id);
8         return SUCCESS;
9     }
View Code

2 完善struts.xml

技术分享
 1 <?xml version="1.0" encoding="UTF-8" ?>
 2 <!DOCTYPE struts PUBLIC
 3     "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
 4     "http://struts.apache.org/dtds/struts-2.3.dtd">
 5 
 6 <struts>
 7 
 8     <constant name="struts.enable.DynamicMethodInvocation" value="false" />
 9     <constant name="struts.devMode" value="true" />
10 
11     <package name="default" namespace="/" extends="struts-default">
12         <action name="emp-*" class="employeeAction"
13                 method="{1}">
14                 <result name="list">/WEB-INF/views/emp-list.jsp</result>
15                  <result name="success" type="redirect">/emp-list</result>
16         </action>
17     </package>
18 
19 </struts>
View Code

3 完善emp-list.jsp

技术分享
1 <td>
2                         <a href="emp-delete?id=${id }">Delete</a>
3                     </td>
View Code

 

 

  

SSH_框架整合3-删除

标签:

原文地址:http://www.cnblogs.com/noaman/p/5883638.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!