首先
使用myeclipse開發hibernate和spring的操作我就不詳細說了
其中持久類AbstractTest
package com
import java
import java
import org
import com
import com
import com
/** *//**
* 描述:
* @author Stone yang 創建日期:
* @version pattern Study
* 技術支持: <a >;/a>
*/
public class TestAction extends ActionSupport
private static final Logger log = Logger
private Integer id;
private Integer[] ids;
protected TestDAO testDao;
private Test test;
private Collection<Test> testColl;
/** *//**
* 描述 return 返回 ids
* @author Stone yang
* @date
*/
public Integer[] getIds()
return ids;
}
/** *//**
* 描述:設置ids的值
* @param ids
* @author Stone yang
* @date
*/
public void setIds(Integer[] ids)
this
}
/** *//**
* 描述 return 返回 testColl
* @author Stone yang
* @date
*/
public Collection<Test> getTestColl()
return testColl;
}
/** *//**
* 描述:設置testColl的值
* @param testColl
* @author Stone yang
* @date
*/
public void setTestColl(Collection<Test> testColl)
this
}
/** *//**
* 描述 return 返回 id
* @author Stone yang
* @date
*/
public Integer getId()
return id;
}
/** *//**
* 描述:設置id的值
* @param id
* @author Stone yang
* @date
*/
public void setId(Integer id)
this
}
/** *//**
* 描述 return 返回 testDao
* @author Stone yang
* @date
*/
public TestDAO getTestDao()
return testDao;
}
/** *//**
* 描述:設置testDao的值
* @param testDao
* @author Stone yang
* @date
*/
public void setTestDao(TestDAO testDao)
this
}
/** *//**
* 描述 return 返回 test
* @author Stone yang
* @date
*/
public Test getTest()
return test;
}
/** *//**
* 描述:設置test的值
* @param test
* @author Stone yang
* @date
*/
public void setTest(Test test)
this
}
public String load()
test = getTestDao()
return SUCCESS;
}
@SuppressWarnings(
public String list()
testColl = getTestDao()
return SUCCESS;
}
public String store()
getTestDao(rge(test);
return SUCCESS;
}
public String remove()
for (int i =
getTestDao()
}
return SUCCESS;
}
}
applicationContext
<?xml version=
<!DOCTYPE beans PUBLIC
<beans>
<bean id=
class=
<property name=
<!
<value>/WEB
</property>
</bean>
<bean id=
class=
<property name=
<ref bean=
</property>
</bean></beans>
struts
<?xml version=
<!DOCTYPE struts PUBLIC
<struts>
<package name=
<action name=
<result>list
</action>
<action name=
<result>edit
</action>
<action name=
<result type=
</action>
<action name=
<result type=
</action>
</package>
</struts>
struts
struts
web
<?xml version=
<web
xmlns=
xmlns:xsi=
xsi:schemaLocation=
<display
<context
<param
<param
</context
<listener>
<listener
</listener>
<filter>
<filter
<filter
org
</filter
</filter>
<filter
<filter
<url
</filter
<welcome
<welcome
</welcome
</web
list
<%
<%
<!DOCTYPE html PUBLIC
<html xmlns=
<head>
<title>Book List</title>
<style type=
table {
border:
border
}
table thead tr th {
border:
padding:
background
}
table tbody tr td {
border:
padding:
}
</style>
</head>
<body>
<h
<s:form action=
<table cellspacing=
<thead>
<tr>
<th>勾選</th>
<th>ID</th>
<th>名稱</th>
<th>作者</th>
</tr>
</thead>
<tbody>
<s:iterator value=
<tr>
<td><input type=
<td><s:property value=
<td><s:property value=
<td><s:property value=
<td>
<a <s:url action=
Edit
</a>
<a <s:url action=
Delete
</a>
</td>
</tr>
</s:iterator>
</tbody>
</table>
<s:submit value=
</s:form>
</body>
</html>
edit
<%
<%
<!DOCTYPE html PUBLIC
<html xmlns=
<head>
<title>Book</title>
</head>
<body>
<h
<s:if test=
Add Book
</s:if>
<s:else>
Edit Book
</s:else>
</h
<s:form action=
<s:hidden name=
<s:textfield name=
<s:textfield name=
<s:submit />
</s:form>
</body>
</html>
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28215.html