- 浏览: 606332 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (263)
- 默认类别 (0)
- STRUTS HIBERNATE (2)
- STRUTS SPRING HIBERNATE (18)
- SOA/WEB service (8)
- PORTAL (3)
- 想法和设计思想 (17)
- SMARTEAM 二次开发 (0)
- ACTIVEBPEL (0)
- ERP (0)
- EAI (0)
- 甲醇汽油 (0)
- webwork freemarker spring hibernate (1)
- 工作流技术研究 (1)
- ROR (5)
- 搜索引擎 (7)
- 3.非技术区 (0)
- 1.网站首页原创Java技术区(对首页文章的要求: 原创、高质量、经过认真思考并精心写作。BlogJava管理团队会对首页的文章进行管理。) (2)
- 2.Java新手区 (2)
- 4.其他技术区 (0)
- ESB (1)
- Petals ESB (6)
- 手机开发 (1)
- docker dedecms (1)
最新评论
-
w630636065:
楼主,期待后续!!!!!!!!
生成文本聚类java实现 (2) -
zilong513:
十分感谢楼主,期待后续。
生成文本聚类java实现 (2) -
qqgoodluck:
可否介绍一下您的选型依据,包括Petal ESB与MULE等E ...
Petals ESB 简介 -
jackiee_cn:
写的比较清楚,学习了
Petals ESB 集群实战 -
忙两夜:
你好,能发一下源代码吗
抓取口碑网店铺资料
本文不关心必须的JAR包,这个东东在网上能够找到很多,本文只关心如何配置,才能够让STRUTS SPRING HIBERNATE和MYSQL相关连。
开发环境:wsad5.1
Spring-Version: 1.1.4
Struts Framework 1.1
Hibernate-Version: 2.1.7
<web.xml>
---------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app id="WebApp">
<display-name>MVC_BPEL_MODELWeb</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/Hibernate_Context.xml</param-value>
</context-param>
<servlet>
<servlet-name>SpringContextServlet</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
</web-app>
-----------------------------------
<action-servlet.xml>
----------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean name="/User" class="com.yaya.action.UserAction" singleton="false">
<property name="userManager">
<ref bean="userManager" />
</property>
</bean>
</beans>
-------------------------------------------------------------------
<hibernate_context.xml>
--------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"><value>org.springframework.web.servlet.view.JstlView</value></property>
<property name="prefix"><value>/WEB-INF/jsp/</value></property>
<property name="suffix"><value>.jsp</value></property>
</bean> -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost/pdm</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value></value>
</property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="mappingResources">
<list>
<value>hbm_tb/TSysuser.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">net.sf.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<!-- Spring的数据访问异常转换器(Data Access Exception Translator)定义 -->
<bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="userDao" class="com.yaya.service.dao.hibernate.UserHibernateDao">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<bean id="userManagerTarget" class="com.yaya.service.spring.UserManagerImpl">
<property name="userDao">
<ref local="userDao" />
</property>
</bean>
<bean id="userManager" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<ref local="userManagerTarget" />
</property>
<property name="proxyTargetClass">
<value>true</value>
</property>
<property name="transactionAttributes">
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="find*">PROPAGATION_REQUIRED</prop>
<prop key="remove*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
</beans>-------------------------------------------------------------------
<struts-config.xml>
-------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<!-- 数据源 -->
<data-sources></data-sources>
<!-- 表单 Bean -->
<form-beans>
<form-bean name="UserActionForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="user" type="com.yaya.hb.TSysuser" />
</form-bean>
</form-beans>
<!-- 全局异常 -->
<global-exceptions></global-exceptions>
<!-- 全局转发 -->
<global-forwards></global-forwards>
<!-- 操作映射 -->
<action-mappings>
<action path="/User" type="org.springframework.web.struts.DelegatingActionProxy"
name="UserActionForm" scope="request" parameter="method" validate="false">
<forward name="list" path="/userlist.jsp" />
<forward name="edit" path="/userform.jsp" />
</action>
</action-mappings>
<!-- 消息资源 -->
<message-resources parameter="mvc_bpel_modelweb.resources.ApplicationResources" />
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/action-servlet.xml" />
</plug-in>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml, /WEB-INF/validation.xml"/>
</plug-in>
</struts-config>
------------------------------------------------------------------
UserHibernateDao.java
------------------------------------------------------------------
/*
* 创建日期 2005-4-7
*
* 更改所生成文件模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
package com.yaya.service.dao.hibernate;
import java.util.List;
import org.springframework.orm.ObjectRetrievalFailureException;
import org.springframework.orm.hibernate.support.HibernateDaoSupport;
import net.sf.hibernate.HibernateException;
import com.yaya.hb.TSysuser;
import com.yaya.service.dao.IUserDao;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author Administrator
*
* 更改所生成类型注释的模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
public class UserHibernateDao extends HibernateDaoSupport implements IUserDao {
private Log log = LogFactory.getLog(UserHibernateDao.class);
/* (非 Javadoc)
* @see com.jandar.dao.IUserDAO#getUsers()
*/
public List getUsers() {
return getHibernateTemplate().find("from TSysuser");
}
/* (非 Javadoc)
* @see com.jandar.dao.IUserDAO#getUser(java.lang.Long)
*/
public TSysuser getUser(String username) {
// TODO 自动生成方法存根
if (this.getHibernateTemplate() == null)
{
System.out.println("error at there");
return null;
}
TSysuser user = (TSysuser) getHibernateTemplate().get(TSysuser.class,username);
//TSysuser user = (TSysuser) getHibernateTemplate().find("from TSysuser users where users.username = 'admin'",username);
if (user == null) {
throw new ObjectRetrievalFailureException(TSysuser.class, username);
}
return user;
//String msg = getHibernateTemplate().get(TSysuser.class,username).toString();
//TSysuser user = (TSysuser) getHibernateTemplate().find("from TSysuser where username = ?",username);
//System.out.println(user.getUserdesc());
//System.out.println(user.getHeadship());
//return user;
}
/* (非 Javadoc)
* @see com.jandar.dao.IUserDAO#saveUser(com.jandar.model.User)
*/
public void saveUser(TSysuser user) {
log.debug("xxxxxxx");
System.out.println("yyyy");
getHibernateTemplate().saveOrUpdate(user);
if (log.isDebugEnabled()) {
log.debug("username set to " + user.getUsername());
}
}
/* (非 Javadoc)
* @see com.jandar.dao.IUserDAO#removeUser(java.lang.Long)
*/
public void removeUser(String username) {
Object user = getHibernateTemplate().load(TSysuser.class, username);
getHibernateTemplate().delete(user);
if (log.isDebugEnabled()) {
log.debug("del user " + username);
}
}
}
-------------------------------------------------------------------
useraction.java
--------------------------------------------------------------------
/*
* 创建日期 2005-4-11
*
* 更改所生成文件模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
package com.yaya.action;
import java.util.Date;
import org.apache.struts.actions.DispatchAction;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.locale.converters.DateLocaleConverter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.action.DynaActionForm;
import org.apache.struts.util.MessageResources;
import com.opensymphony.user.User;
import com.yaya.axis.SpringBeanProvider;
import com.yaya.hb.TSysuser;
import com.yaya.service.spring.UserManagerImpl;
/**
* @author Administrator
*
* 更改所生成类型注释的模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
public class UserAction extends DispatchAction {
private static Log log = LogFactory.getLog(UserAction.class);
private UserManagerImpl mgr = null;
public void setUserManager(UserManagerImpl userManager) {
this.mgr = userManager;
}
public ActionForward delete(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
if (log.isDebugEnabled()) {
log.debug("entering 'delete' method...");
}
mgr.removeUser(request.getParameter("user.username"));
ActionMessages messages = new ActionMessages();
messages.add(
ActionMessages.GLOBAL_MESSAGE,
new ActionMessage("user.deleted"));
saveMessages(request, messages);
return list(mapping, form, request, response);
}
public ActionForward edit(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
if (log.isDebugEnabled()) {
log.debug("entering 'edit' method...");
}
DynaActionForm UserActionForm = (DynaActionForm) form;
String username = request.getParameter("username");
// null userId indicates an add
if (username != null) {
try
{
TSysuser user = mgr.getUser(username);
if (user == null) {
ActionMessages errors = new ActionMessages();
errors.add(
ActionMessages.GLOBAL_MESSAGE,
new ActionMessage("user.missing"));
saveErrors(request, (ActionErrors) errors);
return mapping.findForward("list");
}
UserActionForm.set("user",user);
//request.setAttribute("user",user);
}
catch(Exception e)
{
e.printStackTrace();
}
}
return mapping.findForward("edit");
}
public ActionForward list(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
if (log.isDebugEnabled()) {
log.debug("entering 'list' method...");
}
request.setAttribute("users", mgr.getUsers());
return mapping.findForward("list");
}
public ActionForward save(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
if (log.isDebugEnabled()) {
log.debug("entering 'save' method...");
}
if (isCancelled(request)) {
return list(mapping, form, request, response);
}
// run validation rules on this form
ActionMessages errors = form.validate(mapping, request);
if (!errors.isEmpty()) {
saveErrors(request, (ActionErrors) errors);
return mapping.findForward("edit");
}
DynaActionForm UserActionForm = (DynaActionForm) form;
TSysuser user = (TSysuser) UserActionForm.get("user");
mgr.saveUser(user);
ActionMessages messages = new ActionMessages();
messages.add(ActionMessages.GLOBAL_MESSAGE,
new ActionMessage("user.saved", user.getUsername()));
//saveMessages((HttpServletRequest) request.getSession(), messages);
return mapping.findForward("list");
}
public ActionForward unspecified(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
return list(mapping, form, request, response);
}
}
-------------------------------------------------------------------
UserActionForm.java
-------------------------------------------------------------------
/*
* 创建日期 2005-3-29
*
* 更改所生成文件模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
package com.yaya.actionform;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
/**
* @author Administrator
*
* 更改所生成类型注释的模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
public class UserActionForm extends ActionForm {
/** identifier field */
private String username;
/** identifier field */
private String userdesc;
/** identifier field */
private String passwords;
/** identifier field */
private String deptno;
/** identifier field */
private String headship;
/** identifier field */
private String sex;
/** identifier field */
private String tel;
/** identifier field */
private String email;
/** identifier field */
private String url;
/** identifier field */
private String pcall;
/** identifier field */
/** identifier field */
private String userphoto;
/** identifier field */
private Integer facerefutime;
/** identifier field */
private String facelanguage;
/** identifier field */
private String lastmodif;
/** identifier field */
private Date lastmdate;
/** identifier field */
private String creadtor;
/** identifier field */
private Date creatdate;
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPasswords() {
return this.passwords;
}
public void setPasswords(String passwords) {
this.passwords = passwords;
}
public String getDeptno() {
return this.deptno;
}
public void setDeptno(String deptno) {
this.deptno = deptno;
}
public String getHeadship() {
return this.headship;
}
public void setHeadship(String headship) {
this.headship = headship;
}
public String getSex() {
return this.sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getTel() {
return this.tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
public String getUrl() {
return this.url;
}
public void setUrl(String url) {
this.url = url;
}
public String getPcall() {
return this.pcall;
}
public void setPcall(String pcall) {
this.pcall = pcall;
}
public String getUserphoto() {
return this.userphoto;
}
public void setUserphoto(String userphoto) {
this.userphoto = userphoto;
}
public Integer getFacerefutime() {
return this.facerefutime;
}
public void setFacerefutime(Integer facerefutime) {
this.facerefutime = facerefutime;
}
public String getFacelanguage() {
return this.facelanguage;
}
public void setFacelanguage(String facelanguage) {
this.facelanguage = facelanguage;
}
public String getLastmodif() {
return this.lastmodif;
}
public void setLastmodif(String lastmodif) {
this.lastmodif = lastmodif;
}
public Date getLastmdate() {
return this.lastmdate;
}
public void setLastmdate(Date lastmdate) {
this.lastmdate = lastmdate;
}
public String getCreadtor() {
return this.creadtor;
}
public void setCreadtor(String creadtor) {
this.creadtor = creadtor;
}
public Date getCreatdate() {
return this.creatdate;
}
public void setCreatdate(Date creatdate) {
this.creatdate = creatdate;
}
/**
* @return
*/
public String getUserdesc() {
return userdesc;
}
/**
* @param string
*/
public void setUserdesc(String string) {
userdesc = string;
}
}
------------------------------------------------------------------
TSysuser.java
------------------------------------------------------------------
package com.yaya.hb;
import java.io.InputStream;
import java.io.Serializable;
import java.util.Date;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
/** @author Hibernate CodeGenerator */
public class TSysuser implements Serializable {
/** identifier field */
private String username;
/** identifier field */
private String userdesc;
/** identifier field */
private String passwords;
/** identifier field */
private String deptno;
/** identifier field */
private String headship;
/** identifier field */
private String sex;
/** identifier field */
private String tel;
/** identifier field */
private String email;
/** identifier field */
private String url;
/** identifier field */
private String pcall;
/** identifier field */
/** identifier field */
private String userphoto;
/** identifier field */
private Integer facerefutime;
/** identifier field */
private String facelanguage;
/** identifier field */
private String lastmodif;
/** identifier field */
private Date lastmdate;
/** identifier field */
private String creadtor;
/** identifier field */
private Date creatdate;
/** full constructor */
public TSysuser(String username, String userdesc, String passwords, String deptno, String headship, String sex, String tel, String email, String url, String pcall, InputStream userimage, String userphoto, Integer facerefutime, String facelanguage, String lastmodif, Date lastmdate, String creadtor, Date creatdate) {
this.username = username;
this.userdesc = userdesc;
this.passwords = passwords;
this.deptno = deptno;
this.headship = headship;
this.sex = sex;
this.tel = tel;
this.email = email;
this.url = url;
this.pcall = pcall;
this.userphoto = userphoto;
this.facerefutime = facerefutime;
this.facelanguage = facelanguage;
this.lastmodif = lastmodif;
this.lastmdate = lastmdate;
this.creadtor = creadtor;
this.creatdate = creatdate;
}
/** default constructor */
public TSysuser() {
}
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUserdesc() {
return this.userdesc;
}
public void setUserdesc(String userdesc) {
this.userdesc = userdesc;
}
public String getPasswords() {
return this.passwords;
}
public void setPasswords(String passwords) {
this.passwords = passwords;
}
public String getDeptno() {
return this.deptno;
}
public void setDeptno(String deptno) {
this.deptno = deptno;
}
public String getHeadship() {
return this.headship;
}
public void setHeadship(String headship) {
this.headship = headship;
}
public String getSex() {
return this.sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getTel() {
return this.tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
public String getUrl() {
return this.url;
}
public void setUrl(String url) {
this.url = url;
}
public String getPcall() {
return this.pcall;
}
public void setPcall(String pcall) {
this.pcall = pcall;
}
public String getUserphoto() {
return this.userphoto;
}
public void setUserphoto(String userphoto) {
this.userphoto = userphoto;
}
public Integer getFacerefutime() {
return this.facerefutime;
}
public void setFacerefutime(Integer facerefutime) {
this.facerefutime = facerefutime;
}
public String getFacelanguage() {
return this.facelanguage;
}
public void setFacelanguage(String facelanguage) {
this.facelanguage = facelanguage;
}
public String getLastmodif() {
return this.lastmodif;
}
public void setLastmodif(String lastmodif) {
this.lastmodif = lastmodif;
}
public Date getLastmdate() {
return this.lastmdate;
}
public void setLastmdate(Date lastmdate) {
this.lastmdate = lastmdate;
}
public String getCreadtor() {
return this.creadtor;
}
public void setCreadtor(String creadtor) {
this.creadtor = creadtor;
}
public Date getCreatdate() {
return this.creatdate;
}
public void setCreatdate(Date creatdate) {
this.creatdate = creatdate;
}
public String toString() {
return new ToStringBuilder(this)
.append("username", getUsername())
.append("userdesc", getUserdesc())
.append("passwords", getPasswords())
.append("deptno", getDeptno())
.append("headship", getHeadship())
.append("sex", getSex())
.append("tel", getTel())
.append("email", getEmail())
.append("url", getUrl())
.append("pcall", getPcall())
.append("userphoto", getUserphoto())
.append("facerefutime", getFacerefutime())
.append("facelanguage", getFacelanguage())
.append("lastmodif", getLastmodif())
.append("lastmdate", getLastmdate())
.append("creadtor", getCreadtor())
.append("creatdate", getCreatdate())
.toString();
}
public boolean equals(Object other) {
if ( !(other instanceof TSysuser) ) return false;
TSysuser castOther = (TSysuser) other;
return new EqualsBuilder()
.append(this.getUsername(), castOther.getUsername())
.append(this.getUserdesc(), castOther.getUserdesc())
.append(this.getPasswords(), castOther.getPasswords())
.append(this.getDeptno(), castOther.getDeptno())
.append(this.getHeadship(), castOther.getHeadship())
.append(this.getSex(), castOther.getSex())
.append(this.getTel(), castOther.getTel())
.append(this.getEmail(), castOther.getEmail())
.append(this.getUrl(), castOther.getUrl())
.append(this.getPcall(), castOther.getPcall())
.append(this.getUserphoto(), castOther.getUserphoto())
.append(this.getFacerefutime(), castOther.getFacerefutime())
.append(this.getFacelanguage(), castOther.getFacelanguage())
.append(this.getLastmodif(), castOther.getLastmodif())
.append(this.getLastmdate(), castOther.getLastmdate())
.append(this.getCreadtor(), castOther.getCreadtor())
.append(this.getCreatdate(), castOther.getCreatdate())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
.append(getUsername())
.append(getUserdesc())
.append(getPasswords())
.append(getDeptno())
.append(getHeadship())
.append(getSex())
.append(getTel())
.append(getEmail())
.append(getUrl())
.append(getPcall())
.append(getUserphoto())
.append(getFacerefutime())
.append(getFacelanguage())
.append(getLastmodif())
.append(getLastmdate())
.append(getCreadtor())
.append(getCreatdate())
.toHashCode();
}
}
---------------------------------------------------------------------
IUserManager.java
---------------------------------------------------------------------
package com.yaya.service;
import java.util.List;
import com.yaya.hb.TSysuser;
import com.yaya.service.dao.IUserDao;
public interface IUserManager {
public void setUserDAO(IUserDao userDao);
public TSysuser getUser(String username);
public List getUsers();
public void saveUser(TSysuser user);
public void removeUser(String username);
}
--------------------------------------------------------------------
IDAO.java
--------------------------------------------------------------------
/*
* 创建日期 2005-4-7
*
* 更改所生成文件模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
package com.yaya.service.dao;
/**
* @author Administrator
*
* 更改所生成类型注释的模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
public interface IDAO {
}
--------------------------------------------------------------
IUserDao.java
--------------------------------------------------------------
/*
* 创建日期 2005-4-11
*
* 更改所生成文件模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
package com.yaya.service.dao;
import java.util.List;
import com.yaya.hb.TSysuser;
/**
* @author Administrator
*
* 更改所生成类型注释的模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
public interface IUserDao extends IDAO {
public List getUsers();
public TSysuser getUser(String username);
public void saveUser(TSysuser user);
public void removeUser(String username);
}
----------------------------------------------------------
UserManagerImpl.java
----------------------------------------------------------
package com.yaya.service.spring;
import com.yaya.hb.TSysuser;
import com.yaya.service.IUserManager;
import com.yaya.service.dao.IUserDao;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class UserManagerImpl implements IUserManager {
private static Log log = LogFactory.getLog(UserManagerImpl.class);
public IUserDao dao;
public void setUserDao(IUserDao userDao) {
this.dao = userDao;
this.setUserDAO(userDao);
}
public TSysuser getUser(String username) {
return dao.getUser(username);
}
public List getUsers() {
return dao.getUsers();
}
public void saveUser(TSysuser user) {
dao.saveUser(user);
}
public void removeUser(String username) {
// TODO 自动生成方法存根
dao.removeUser(username);
}
public void setUserDAO(IUserDao dao) {
// TODO 自动生成方法存根
this.dao = dao;
}
}
-----------------------------------------------------------------
TSysuser.hbm.xml
-----------------------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class name="com.yaya.hb.TSysuser" table="t_sysuser">
<id name="username" type="java.lang.String" column="USERNAME">
<generator class="identity" />
</id>
<property name="userdesc" type="java.lang.String" column="USERDESC" length="30" />
<property name="passwords" type="java.lang.String" column="PASSWORDS" length="30" />
<property name="deptno" type="java.lang.String" column="DEPTNO" length="30" />
<property name="headship" type="java.lang.String" column="HEADSHIP" length="30" />
<property name="sex" type="java.lang.String" column="SEX" length="4" />
<property name="tel" type="java.lang.String" column="TEL" length="18" />
<property name="email" type="java.lang.String" column="EMAIL" length="30" />
<property name="url" type="java.lang.String" column="URL" length="30" />
<property name="pcall" type="java.lang.String" column="PCALL" length="20" />
<property name="userphoto" type="java.lang.String" column="USERPHOTO" length="255" />
<property name="facerefutime" type="java.lang.Integer" column="FACEREFUTIME" length="6" />
<property name="facelanguage" type="java.lang.String" column="FACELANGUAGE" length="1" />
<property name="lastmodif" type="java.lang.String" column="LASTMODIF" length="30" />
<property name="lastmdate" type="java.sql.Timestamp" column="LASTMDATE" length="19" />
<property name="creadtor" type="java.lang.String" column="CREADTOR" length="30" />
<property name="creatdate" type="java.sql.Timestamp" column="CREATDATE" length="19" />
<!-- associations -->
</class>
</hibernate-mapping>
-------------------------------------------------------------------
创建数据库脚本 用于MYSQL
-------------------------------------------------------------------
CREATE TABLE `t_sysuser` (
`USERNAME` varchar(30) NOT NULL default '',
`USERDESC` varchar(30) default NULL,
`PASSWORDS` varchar(30) default NULL,
`DEPTNO` varchar(30) default NULL,
`HEADSHIP` varchar(30) default NULL,
`SEX` varchar(4) default NULL,
`TEL` varchar(18) default NULL,
`EMAIL` varchar(30) default NULL,
`URL` varchar(30) default NULL,
`PCALL` varchar(20) default NULL,
`USERPHOTO` varchar(255) default NULL,
`FACEREFUTIME` decimal(6,0) default NULL,
`FACELANGUAGE` char(1) default NULL,
`LASTMODIF` varchar(30) default NULL,
`LASTMDATE` datetime default NULL,
`CREADTOR` varchar(30) default NULL,
`CREATDATE` datetime default NULL,
PRIMARY KEY (`USERNAME`)
) TYPE=MyISAM;
-----------------------------------------------------------
提示:COPY几个资源文件
validation.xml 和 validator-rules.xml
前台使用的几个JSP文件如下:
-----------------------------------------------------------
index.jsp
-----------------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class name="com.yaya.hb.TSysuser" table="t_sysuser">
<id name="username" type="java.lang.String" column="USERNAME">
<generator class="identity" />
</id>
<property name="userdesc" type="java.lang.String" column="USERDESC" length="30" />
<property name="passwords" type="java.lang.String" column="PASSWORDS" length="30" />
<property name="deptno" type="java.lang.String" column="DEPTNO" length="30" />
<property name="headship" type="java.lang.String" column="HEADSHIP" length="30" />
<property name="sex" type="java.lang.String" column="SEX" length="4" />
<property name="tel" type="java.lang.String" column="TEL" length="18" />
<property name="email" type="java.lang.String" column="EMAIL" length="30" />
<property name="url" type="java.lang.String" column="URL" length="30" />
<property name="pcall" type="java.lang.String" column="PCALL" length="20" />
<property name="userphoto" type="java.lang.String" column="USERPHOTO" length="255" />
<property name="facerefutime" type="java.lang.Integer" column="FACEREFUTIME" length="6" />
<property name="facelanguage" type="java.lang.String" column="FACELANGUAGE" length="1" />
<property name="lastmodif" type="java.lang.String" column="LASTMODIF" length="30" />
<property name="lastmdate" type="java.sql.Timestamp" column="LASTMDATE" length="19" />
<property name="creadtor" type="java.lang.String" column="CREADTOR" length="30" />
<property name="creatdate" type="java.sql.Timestamp" column="CREATDATE" length="19" />
<!-- associations -->
</class>
</hibernate-mapping>
------------------------------------------------------------------
userlist.jsp
------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html:html locale="true">
<head>
<title><bean:message key="pdmweb.title"/></title>
</head>
<body>
<table class="list">
<thead>
<tr bgcolor="#8080ff">
<td bgcolor="#8080ff"><bean:message key="listuser.username" /></td>
<td bgcolor="#8080ff"><bean:message key="listuser.userdesc" /></td>
<td bgcolor="#8080ff"><bean:message key="listuser.sex" /></td>
</tr>
</thead>
<tbody>
<logic:iterate id="user" name="users">
<tr>
<td bgcolor="#ff8040"><A href="User.do?method=edit&username=<bean:write name="user" property="username"/>" ><bean:write name="user" property="username" />
</a>
</td>
<td bgcolor="#ff8040"><bean:write name="user" property="userdesc" /></td>
<td bgcolor="#ff8040"><logic:equal name="user" property="sex" value="0">
<bean:message key="listuser.sex0" />
</logic:equal> <logic:equal name="user" property="sex" value="1">
<bean:message key="listuser.sex1" />
</logic:equal></td>
</tr>
</logic:iterate>
</tbody>
</table>
</body>
</html:html>
-------------------------------------------------------------------
userform.jsp
------------------------------------------------------------------
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html locale="true">
<head>
<html:base />
<title>userform.jsp</title>
</head>
<body>
<html:form action="User.do?method=save" method="post" focus="user.userdesc" >
<html:text property="user.username" />
<br>
<html:text property="user.userdesc" /><br>
<html:text property="user.deptno" /><br>
<html:submit property="tijiao" />
</html:form>
</body>
</html:html>
--------------------------------------------------------------
如果有什么疑问可以致电邮至 heweiya@yahoo.com.cn,互相交流,互相学习。
开发环境:wsad5.1
Spring-Version: 1.1.4
Struts Framework 1.1
Hibernate-Version: 2.1.7
<web.xml>
---------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app id="WebApp">
<display-name>MVC_BPEL_MODELWeb</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/Hibernate_Context.xml</param-value>
</context-param>
<servlet>
<servlet-name>SpringContextServlet</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
</web-app>
-----------------------------------
<action-servlet.xml>
----------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean name="/User" class="com.yaya.action.UserAction" singleton="false">
<property name="userManager">
<ref bean="userManager" />
</property>
</bean>
</beans>
-------------------------------------------------------------------
<hibernate_context.xml>
--------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"><value>org.springframework.web.servlet.view.JstlView</value></property>
<property name="prefix"><value>/WEB-INF/jsp/</value></property>
<property name="suffix"><value>.jsp</value></property>
</bean> -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost/pdm</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value></value>
</property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="mappingResources">
<list>
<value>hbm_tb/TSysuser.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">net.sf.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<!-- Spring的数据访问异常转换器(Data Access Exception Translator)定义 -->
<bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="userDao" class="com.yaya.service.dao.hibernate.UserHibernateDao">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<bean id="userManagerTarget" class="com.yaya.service.spring.UserManagerImpl">
<property name="userDao">
<ref local="userDao" />
</property>
</bean>
<bean id="userManager" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<ref local="userManagerTarget" />
</property>
<property name="proxyTargetClass">
<value>true</value>
</property>
<property name="transactionAttributes">
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="find*">PROPAGATION_REQUIRED</prop>
<prop key="remove*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
</beans>-------------------------------------------------------------------
<struts-config.xml>
-------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<!-- 数据源 -->
<data-sources></data-sources>
<!-- 表单 Bean -->
<form-beans>
<form-bean name="UserActionForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="user" type="com.yaya.hb.TSysuser" />
</form-bean>
</form-beans>
<!-- 全局异常 -->
<global-exceptions></global-exceptions>
<!-- 全局转发 -->
<global-forwards></global-forwards>
<!-- 操作映射 -->
<action-mappings>
<action path="/User" type="org.springframework.web.struts.DelegatingActionProxy"
name="UserActionForm" scope="request" parameter="method" validate="false">
<forward name="list" path="/userlist.jsp" />
<forward name="edit" path="/userform.jsp" />
</action>
</action-mappings>
<!-- 消息资源 -->
<message-resources parameter="mvc_bpel_modelweb.resources.ApplicationResources" />
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/action-servlet.xml" />
</plug-in>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml, /WEB-INF/validation.xml"/>
</plug-in>
</struts-config>
------------------------------------------------------------------
UserHibernateDao.java
------------------------------------------------------------------
/*
* 创建日期 2005-4-7
*
* 更改所生成文件模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
package com.yaya.service.dao.hibernate;
import java.util.List;
import org.springframework.orm.ObjectRetrievalFailureException;
import org.springframework.orm.hibernate.support.HibernateDaoSupport;
import net.sf.hibernate.HibernateException;
import com.yaya.hb.TSysuser;
import com.yaya.service.dao.IUserDao;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author Administrator
*
* 更改所生成类型注释的模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
public class UserHibernateDao extends HibernateDaoSupport implements IUserDao {
private Log log = LogFactory.getLog(UserHibernateDao.class);
/* (非 Javadoc)
* @see com.jandar.dao.IUserDAO#getUsers()
*/
public List getUsers() {
return getHibernateTemplate().find("from TSysuser");
}
/* (非 Javadoc)
* @see com.jandar.dao.IUserDAO#getUser(java.lang.Long)
*/
public TSysuser getUser(String username) {
// TODO 自动生成方法存根
if (this.getHibernateTemplate() == null)
{
System.out.println("error at there");
return null;
}
TSysuser user = (TSysuser) getHibernateTemplate().get(TSysuser.class,username);
//TSysuser user = (TSysuser) getHibernateTemplate().find("from TSysuser users where users.username = 'admin'",username);
if (user == null) {
throw new ObjectRetrievalFailureException(TSysuser.class, username);
}
return user;
//String msg = getHibernateTemplate().get(TSysuser.class,username).toString();
//TSysuser user = (TSysuser) getHibernateTemplate().find("from TSysuser where username = ?",username);
//System.out.println(user.getUserdesc());
//System.out.println(user.getHeadship());
//return user;
}
/* (非 Javadoc)
* @see com.jandar.dao.IUserDAO#saveUser(com.jandar.model.User)
*/
public void saveUser(TSysuser user) {
log.debug("xxxxxxx");
System.out.println("yyyy");
getHibernateTemplate().saveOrUpdate(user);
if (log.isDebugEnabled()) {
log.debug("username set to " + user.getUsername());
}
}
/* (非 Javadoc)
* @see com.jandar.dao.IUserDAO#removeUser(java.lang.Long)
*/
public void removeUser(String username) {
Object user = getHibernateTemplate().load(TSysuser.class, username);
getHibernateTemplate().delete(user);
if (log.isDebugEnabled()) {
log.debug("del user " + username);
}
}
}
-------------------------------------------------------------------
useraction.java
--------------------------------------------------------------------
/*
* 创建日期 2005-4-11
*
* 更改所生成文件模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
package com.yaya.action;
import java.util.Date;
import org.apache.struts.actions.DispatchAction;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.locale.converters.DateLocaleConverter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.action.DynaActionForm;
import org.apache.struts.util.MessageResources;
import com.opensymphony.user.User;
import com.yaya.axis.SpringBeanProvider;
import com.yaya.hb.TSysuser;
import com.yaya.service.spring.UserManagerImpl;
/**
* @author Administrator
*
* 更改所生成类型注释的模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
public class UserAction extends DispatchAction {
private static Log log = LogFactory.getLog(UserAction.class);
private UserManagerImpl mgr = null;
public void setUserManager(UserManagerImpl userManager) {
this.mgr = userManager;
}
public ActionForward delete(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
if (log.isDebugEnabled()) {
log.debug("entering 'delete' method...");
}
mgr.removeUser(request.getParameter("user.username"));
ActionMessages messages = new ActionMessages();
messages.add(
ActionMessages.GLOBAL_MESSAGE,
new ActionMessage("user.deleted"));
saveMessages(request, messages);
return list(mapping, form, request, response);
}
public ActionForward edit(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
if (log.isDebugEnabled()) {
log.debug("entering 'edit' method...");
}
DynaActionForm UserActionForm = (DynaActionForm) form;
String username = request.getParameter("username");
// null userId indicates an add
if (username != null) {
try
{
TSysuser user = mgr.getUser(username);
if (user == null) {
ActionMessages errors = new ActionMessages();
errors.add(
ActionMessages.GLOBAL_MESSAGE,
new ActionMessage("user.missing"));
saveErrors(request, (ActionErrors) errors);
return mapping.findForward("list");
}
UserActionForm.set("user",user);
//request.setAttribute("user",user);
}
catch(Exception e)
{
e.printStackTrace();
}
}
return mapping.findForward("edit");
}
public ActionForward list(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
if (log.isDebugEnabled()) {
log.debug("entering 'list' method...");
}
request.setAttribute("users", mgr.getUsers());
return mapping.findForward("list");
}
public ActionForward save(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
if (log.isDebugEnabled()) {
log.debug("entering 'save' method...");
}
if (isCancelled(request)) {
return list(mapping, form, request, response);
}
// run validation rules on this form
ActionMessages errors = form.validate(mapping, request);
if (!errors.isEmpty()) {
saveErrors(request, (ActionErrors) errors);
return mapping.findForward("edit");
}
DynaActionForm UserActionForm = (DynaActionForm) form;
TSysuser user = (TSysuser) UserActionForm.get("user");
mgr.saveUser(user);
ActionMessages messages = new ActionMessages();
messages.add(ActionMessages.GLOBAL_MESSAGE,
new ActionMessage("user.saved", user.getUsername()));
//saveMessages((HttpServletRequest) request.getSession(), messages);
return mapping.findForward("list");
}
public ActionForward unspecified(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
return list(mapping, form, request, response);
}
}
-------------------------------------------------------------------
UserActionForm.java
-------------------------------------------------------------------
/*
* 创建日期 2005-3-29
*
* 更改所生成文件模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
package com.yaya.actionform;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
/**
* @author Administrator
*
* 更改所生成类型注释的模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
public class UserActionForm extends ActionForm {
/** identifier field */
private String username;
/** identifier field */
private String userdesc;
/** identifier field */
private String passwords;
/** identifier field */
private String deptno;
/** identifier field */
private String headship;
/** identifier field */
private String sex;
/** identifier field */
private String tel;
/** identifier field */
private String email;
/** identifier field */
private String url;
/** identifier field */
private String pcall;
/** identifier field */
/** identifier field */
private String userphoto;
/** identifier field */
private Integer facerefutime;
/** identifier field */
private String facelanguage;
/** identifier field */
private String lastmodif;
/** identifier field */
private Date lastmdate;
/** identifier field */
private String creadtor;
/** identifier field */
private Date creatdate;
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPasswords() {
return this.passwords;
}
public void setPasswords(String passwords) {
this.passwords = passwords;
}
public String getDeptno() {
return this.deptno;
}
public void setDeptno(String deptno) {
this.deptno = deptno;
}
public String getHeadship() {
return this.headship;
}
public void setHeadship(String headship) {
this.headship = headship;
}
public String getSex() {
return this.sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getTel() {
return this.tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
public String getUrl() {
return this.url;
}
public void setUrl(String url) {
this.url = url;
}
public String getPcall() {
return this.pcall;
}
public void setPcall(String pcall) {
this.pcall = pcall;
}
public String getUserphoto() {
return this.userphoto;
}
public void setUserphoto(String userphoto) {
this.userphoto = userphoto;
}
public Integer getFacerefutime() {
return this.facerefutime;
}
public void setFacerefutime(Integer facerefutime) {
this.facerefutime = facerefutime;
}
public String getFacelanguage() {
return this.facelanguage;
}
public void setFacelanguage(String facelanguage) {
this.facelanguage = facelanguage;
}
public String getLastmodif() {
return this.lastmodif;
}
public void setLastmodif(String lastmodif) {
this.lastmodif = lastmodif;
}
public Date getLastmdate() {
return this.lastmdate;
}
public void setLastmdate(Date lastmdate) {
this.lastmdate = lastmdate;
}
public String getCreadtor() {
return this.creadtor;
}
public void setCreadtor(String creadtor) {
this.creadtor = creadtor;
}
public Date getCreatdate() {
return this.creatdate;
}
public void setCreatdate(Date creatdate) {
this.creatdate = creatdate;
}
/**
* @return
*/
public String getUserdesc() {
return userdesc;
}
/**
* @param string
*/
public void setUserdesc(String string) {
userdesc = string;
}
}
------------------------------------------------------------------
TSysuser.java
------------------------------------------------------------------
package com.yaya.hb;
import java.io.InputStream;
import java.io.Serializable;
import java.util.Date;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
/** @author Hibernate CodeGenerator */
public class TSysuser implements Serializable {
/** identifier field */
private String username;
/** identifier field */
private String userdesc;
/** identifier field */
private String passwords;
/** identifier field */
private String deptno;
/** identifier field */
private String headship;
/** identifier field */
private String sex;
/** identifier field */
private String tel;
/** identifier field */
private String email;
/** identifier field */
private String url;
/** identifier field */
private String pcall;
/** identifier field */
/** identifier field */
private String userphoto;
/** identifier field */
private Integer facerefutime;
/** identifier field */
private String facelanguage;
/** identifier field */
private String lastmodif;
/** identifier field */
private Date lastmdate;
/** identifier field */
private String creadtor;
/** identifier field */
private Date creatdate;
/** full constructor */
public TSysuser(String username, String userdesc, String passwords, String deptno, String headship, String sex, String tel, String email, String url, String pcall, InputStream userimage, String userphoto, Integer facerefutime, String facelanguage, String lastmodif, Date lastmdate, String creadtor, Date creatdate) {
this.username = username;
this.userdesc = userdesc;
this.passwords = passwords;
this.deptno = deptno;
this.headship = headship;
this.sex = sex;
this.tel = tel;
this.email = email;
this.url = url;
this.pcall = pcall;
this.userphoto = userphoto;
this.facerefutime = facerefutime;
this.facelanguage = facelanguage;
this.lastmodif = lastmodif;
this.lastmdate = lastmdate;
this.creadtor = creadtor;
this.creatdate = creatdate;
}
/** default constructor */
public TSysuser() {
}
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUserdesc() {
return this.userdesc;
}
public void setUserdesc(String userdesc) {
this.userdesc = userdesc;
}
public String getPasswords() {
return this.passwords;
}
public void setPasswords(String passwords) {
this.passwords = passwords;
}
public String getDeptno() {
return this.deptno;
}
public void setDeptno(String deptno) {
this.deptno = deptno;
}
public String getHeadship() {
return this.headship;
}
public void setHeadship(String headship) {
this.headship = headship;
}
public String getSex() {
return this.sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getTel() {
return this.tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
public String getUrl() {
return this.url;
}
public void setUrl(String url) {
this.url = url;
}
public String getPcall() {
return this.pcall;
}
public void setPcall(String pcall) {
this.pcall = pcall;
}
public String getUserphoto() {
return this.userphoto;
}
public void setUserphoto(String userphoto) {
this.userphoto = userphoto;
}
public Integer getFacerefutime() {
return this.facerefutime;
}
public void setFacerefutime(Integer facerefutime) {
this.facerefutime = facerefutime;
}
public String getFacelanguage() {
return this.facelanguage;
}
public void setFacelanguage(String facelanguage) {
this.facelanguage = facelanguage;
}
public String getLastmodif() {
return this.lastmodif;
}
public void setLastmodif(String lastmodif) {
this.lastmodif = lastmodif;
}
public Date getLastmdate() {
return this.lastmdate;
}
public void setLastmdate(Date lastmdate) {
this.lastmdate = lastmdate;
}
public String getCreadtor() {
return this.creadtor;
}
public void setCreadtor(String creadtor) {
this.creadtor = creadtor;
}
public Date getCreatdate() {
return this.creatdate;
}
public void setCreatdate(Date creatdate) {
this.creatdate = creatdate;
}
public String toString() {
return new ToStringBuilder(this)
.append("username", getUsername())
.append("userdesc", getUserdesc())
.append("passwords", getPasswords())
.append("deptno", getDeptno())
.append("headship", getHeadship())
.append("sex", getSex())
.append("tel", getTel())
.append("email", getEmail())
.append("url", getUrl())
.append("pcall", getPcall())
.append("userphoto", getUserphoto())
.append("facerefutime", getFacerefutime())
.append("facelanguage", getFacelanguage())
.append("lastmodif", getLastmodif())
.append("lastmdate", getLastmdate())
.append("creadtor", getCreadtor())
.append("creatdate", getCreatdate())
.toString();
}
public boolean equals(Object other) {
if ( !(other instanceof TSysuser) ) return false;
TSysuser castOther = (TSysuser) other;
return new EqualsBuilder()
.append(this.getUsername(), castOther.getUsername())
.append(this.getUserdesc(), castOther.getUserdesc())
.append(this.getPasswords(), castOther.getPasswords())
.append(this.getDeptno(), castOther.getDeptno())
.append(this.getHeadship(), castOther.getHeadship())
.append(this.getSex(), castOther.getSex())
.append(this.getTel(), castOther.getTel())
.append(this.getEmail(), castOther.getEmail())
.append(this.getUrl(), castOther.getUrl())
.append(this.getPcall(), castOther.getPcall())
.append(this.getUserphoto(), castOther.getUserphoto())
.append(this.getFacerefutime(), castOther.getFacerefutime())
.append(this.getFacelanguage(), castOther.getFacelanguage())
.append(this.getLastmodif(), castOther.getLastmodif())
.append(this.getLastmdate(), castOther.getLastmdate())
.append(this.getCreadtor(), castOther.getCreadtor())
.append(this.getCreatdate(), castOther.getCreatdate())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
.append(getUsername())
.append(getUserdesc())
.append(getPasswords())
.append(getDeptno())
.append(getHeadship())
.append(getSex())
.append(getTel())
.append(getEmail())
.append(getUrl())
.append(getPcall())
.append(getUserphoto())
.append(getFacerefutime())
.append(getFacelanguage())
.append(getLastmodif())
.append(getLastmdate())
.append(getCreadtor())
.append(getCreatdate())
.toHashCode();
}
}
---------------------------------------------------------------------
IUserManager.java
---------------------------------------------------------------------
package com.yaya.service;
import java.util.List;
import com.yaya.hb.TSysuser;
import com.yaya.service.dao.IUserDao;
public interface IUserManager {
public void setUserDAO(IUserDao userDao);
public TSysuser getUser(String username);
public List getUsers();
public void saveUser(TSysuser user);
public void removeUser(String username);
}
--------------------------------------------------------------------
IDAO.java
--------------------------------------------------------------------
/*
* 创建日期 2005-4-7
*
* 更改所生成文件模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
package com.yaya.service.dao;
/**
* @author Administrator
*
* 更改所生成类型注释的模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
public interface IDAO {
}
--------------------------------------------------------------
IUserDao.java
--------------------------------------------------------------
/*
* 创建日期 2005-4-11
*
* 更改所生成文件模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
package com.yaya.service.dao;
import java.util.List;
import com.yaya.hb.TSysuser;
/**
* @author Administrator
*
* 更改所生成类型注释的模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
public interface IUserDao extends IDAO {
public List getUsers();
public TSysuser getUser(String username);
public void saveUser(TSysuser user);
public void removeUser(String username);
}
----------------------------------------------------------
UserManagerImpl.java
----------------------------------------------------------
package com.yaya.service.spring;
import com.yaya.hb.TSysuser;
import com.yaya.service.IUserManager;
import com.yaya.service.dao.IUserDao;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class UserManagerImpl implements IUserManager {
private static Log log = LogFactory.getLog(UserManagerImpl.class);
public IUserDao dao;
public void setUserDao(IUserDao userDao) {
this.dao = userDao;
this.setUserDAO(userDao);
}
public TSysuser getUser(String username) {
return dao.getUser(username);
}
public List getUsers() {
return dao.getUsers();
}
public void saveUser(TSysuser user) {
dao.saveUser(user);
}
public void removeUser(String username) {
// TODO 自动生成方法存根
dao.removeUser(username);
}
public void setUserDAO(IUserDao dao) {
// TODO 自动生成方法存根
this.dao = dao;
}
}
-----------------------------------------------------------------
TSysuser.hbm.xml
-----------------------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class name="com.yaya.hb.TSysuser" table="t_sysuser">
<id name="username" type="java.lang.String" column="USERNAME">
<generator class="identity" />
</id>
<property name="userdesc" type="java.lang.String" column="USERDESC" length="30" />
<property name="passwords" type="java.lang.String" column="PASSWORDS" length="30" />
<property name="deptno" type="java.lang.String" column="DEPTNO" length="30" />
<property name="headship" type="java.lang.String" column="HEADSHIP" length="30" />
<property name="sex" type="java.lang.String" column="SEX" length="4" />
<property name="tel" type="java.lang.String" column="TEL" length="18" />
<property name="email" type="java.lang.String" column="EMAIL" length="30" />
<property name="url" type="java.lang.String" column="URL" length="30" />
<property name="pcall" type="java.lang.String" column="PCALL" length="20" />
<property name="userphoto" type="java.lang.String" column="USERPHOTO" length="255" />
<property name="facerefutime" type="java.lang.Integer" column="FACEREFUTIME" length="6" />
<property name="facelanguage" type="java.lang.String" column="FACELANGUAGE" length="1" />
<property name="lastmodif" type="java.lang.String" column="LASTMODIF" length="30" />
<property name="lastmdate" type="java.sql.Timestamp" column="LASTMDATE" length="19" />
<property name="creadtor" type="java.lang.String" column="CREADTOR" length="30" />
<property name="creatdate" type="java.sql.Timestamp" column="CREATDATE" length="19" />
<!-- associations -->
</class>
</hibernate-mapping>
-------------------------------------------------------------------
创建数据库脚本 用于MYSQL
-------------------------------------------------------------------
CREATE TABLE `t_sysuser` (
`USERNAME` varchar(30) NOT NULL default '',
`USERDESC` varchar(30) default NULL,
`PASSWORDS` varchar(30) default NULL,
`DEPTNO` varchar(30) default NULL,
`HEADSHIP` varchar(30) default NULL,
`SEX` varchar(4) default NULL,
`TEL` varchar(18) default NULL,
`EMAIL` varchar(30) default NULL,
`URL` varchar(30) default NULL,
`PCALL` varchar(20) default NULL,
`USERPHOTO` varchar(255) default NULL,
`FACEREFUTIME` decimal(6,0) default NULL,
`FACELANGUAGE` char(1) default NULL,
`LASTMODIF` varchar(30) default NULL,
`LASTMDATE` datetime default NULL,
`CREADTOR` varchar(30) default NULL,
`CREATDATE` datetime default NULL,
PRIMARY KEY (`USERNAME`)
) TYPE=MyISAM;
-----------------------------------------------------------
提示:COPY几个资源文件
validation.xml 和 validator-rules.xml
前台使用的几个JSP文件如下:
-----------------------------------------------------------
index.jsp
-----------------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class name="com.yaya.hb.TSysuser" table="t_sysuser">
<id name="username" type="java.lang.String" column="USERNAME">
<generator class="identity" />
</id>
<property name="userdesc" type="java.lang.String" column="USERDESC" length="30" />
<property name="passwords" type="java.lang.String" column="PASSWORDS" length="30" />
<property name="deptno" type="java.lang.String" column="DEPTNO" length="30" />
<property name="headship" type="java.lang.String" column="HEADSHIP" length="30" />
<property name="sex" type="java.lang.String" column="SEX" length="4" />
<property name="tel" type="java.lang.String" column="TEL" length="18" />
<property name="email" type="java.lang.String" column="EMAIL" length="30" />
<property name="url" type="java.lang.String" column="URL" length="30" />
<property name="pcall" type="java.lang.String" column="PCALL" length="20" />
<property name="userphoto" type="java.lang.String" column="USERPHOTO" length="255" />
<property name="facerefutime" type="java.lang.Integer" column="FACEREFUTIME" length="6" />
<property name="facelanguage" type="java.lang.String" column="FACELANGUAGE" length="1" />
<property name="lastmodif" type="java.lang.String" column="LASTMODIF" length="30" />
<property name="lastmdate" type="java.sql.Timestamp" column="LASTMDATE" length="19" />
<property name="creadtor" type="java.lang.String" column="CREADTOR" length="30" />
<property name="creatdate" type="java.sql.Timestamp" column="CREATDATE" length="19" />
<!-- associations -->
</class>
</hibernate-mapping>
------------------------------------------------------------------
userlist.jsp
------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html:html locale="true">
<head>
<title><bean:message key="pdmweb.title"/></title>
</head>
<body>
<table class="list">
<thead>
<tr bgcolor="#8080ff">
<td bgcolor="#8080ff"><bean:message key="listuser.username" /></td>
<td bgcolor="#8080ff"><bean:message key="listuser.userdesc" /></td>
<td bgcolor="#8080ff"><bean:message key="listuser.sex" /></td>
</tr>
</thead>
<tbody>
<logic:iterate id="user" name="users">
<tr>
<td bgcolor="#ff8040"><A href="User.do?method=edit&username=<bean:write name="user" property="username"/>" ><bean:write name="user" property="username" />
</a>
</td>
<td bgcolor="#ff8040"><bean:write name="user" property="userdesc" /></td>
<td bgcolor="#ff8040"><logic:equal name="user" property="sex" value="0">
<bean:message key="listuser.sex0" />
</logic:equal> <logic:equal name="user" property="sex" value="1">
<bean:message key="listuser.sex1" />
</logic:equal></td>
</tr>
</logic:iterate>
</tbody>
</table>
</body>
</html:html>
-------------------------------------------------------------------
userform.jsp
------------------------------------------------------------------
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html locale="true">
<head>
<html:base />
<title>userform.jsp</title>
</head>
<body>
<html:form action="User.do?method=save" method="post" focus="user.userdesc" >
<html:text property="user.username" />
<br>
<html:text property="user.userdesc" /><br>
<html:text property="user.deptno" /><br>
<html:submit property="tijiao" />
</html:form>
</body>
</html:html>
--------------------------------------------------------------
如果有什么疑问可以致电邮至 heweiya@yahoo.com.cn,互相交流,互相学习。
相关推荐
简单struts+spring+hibernate搭建,配置,适合初学者
标题和描述中指出的文档《Struts+Spring+Hibernate开发实例.pdf》包含了关于这三个流行的Java开源框架结合使用的示例代码和相关知识点。Struts负责视图与控制器部分,Spring负责业务逻辑层及依赖注入,Hibernate负责...
DWR+Struts+spring+hibernate的订货系统,自己添加的dwr功能
同时使用了Struts2、Spring4、Hibernate4、log4j、slf4j、junit4、ehcache等库或框架,搭建一个最基本的项目原型。 三、 三大框架最新版本下载:截止2014-10-01 Struts2.3.6:发布于2014-05-03,目前的最新版本。...
基于struts+spring+hibernate+oracle的移动ssh项目源码 基于struts+spring+hibernate+oracle的移动ssh项目源码 基于struts+spring+hibernate+oracle的移动ssh项目源码 基于struts+spring+hibernate+oracle的移动ssh...
Struts1.2、Spring2.5和Hibernate3.2是经典的Java企业级开发框架组合,它们各自在应用程序的不同层次上发挥着重要作用。Struts1.2是一个MVC(Model-View-Controller)框架,主要负责处理用户界面与业务逻辑之间的...
struts2+spring+hibernate 配置文件struts2+spring+hibernate 配置文件
SSH(Struts+Spring+Hibernate)是Java Web开发中一种常见的技术栈,它将MVC设计模式、依赖注入和持久层框架集成为一个整体,大大提高了开发效率和代码的可维护性。下面我们将深入探讨SSH框架的各个组成部分及其结合...
农业网站 (ssh) struts 2 +spring+ hibernate农业网站 (ssh) struts 2 +spring+ hibernate农业网站 (ssh) struts 2 +spring+ hibernate农业网站 (ssh) struts 2 +spring+ hibernate农业网站 (ssh) struts ...
基于spring实现的网上订餐系统(struts+spring+hibernate+SQL Server) 基于spring实现的网上订餐系统(struts+spring+hibernate+SQL Server) 基于spring实现的网上订餐系统(struts+spring+hibernate+SQL Server) 基于...
SSH整合的关键在于配置文件,包括Struts 2的struts.xml、Spring的applicationContext.xml和Hibernate的hibernate.cfg.xml。这些文件定义了各组件之间的关系和行为。例如,struts.xml中配置Action类及其结果视图,...
基于JavaWeb实现的图书管理系统(struts+spring+hibernate+SQL Server) 基于JavaWeb实现的图书管理系统(struts+spring+hibernate+SQL Server) 基于JavaWeb实现的图书管理系统(struts+spring+hibernate+SQL Server) ...
网上订餐系统(struts+spring+hibernate).rar 网上订餐设计主要采用采用MYSQL数据库进行数据表的设计,利用JSP的动态生成页面编程技术, 实现了用网络展示餐饮信息、浏览餐饮页面、注册客户、更改客户信息;同时,...
1. **使用Spring的ActionSupport**:Action类直接继承自Spring的ActionSupport,通过`super.getWebApplicationContext()`获取Spring上下文,然后通过`ApplicationContext.getBean()`获取bean。这种方式简单,但...
一个简单的spring+struts2+hibernate+mybatis整合(数据库脚本放在项目资源文件的sql目录下) 因为没想好mvc用springmvc好,还是struts2好 所以没有整合进去
Struts、Spring、Hibernate(SSH)是Java Web开发中三个非常重要的开源框架,它们分别用于MVC模式的实现、依赖注入和持久化管理。SSH整合是将这三个框架结合在一起,以构建更高效、可维护性更强的企业级应用。本文...
SSH(Struts+Spring+Hibernate)是一个经典的Java Web开发框架,用于构建高效、可扩展的企业级应用程序。这个教务管理信息系统是基于SSH框架实现的,提供了完整的源代码,可以直接运行,便于开发者学习和参考。 **...
总的来说,这个"struts2+spring2.5+hibernate3.2整合完整项目"提供了一个完整的开发实例,涵盖了前端到后端,以及数据库的各个环节。对于学习者而言,可以深入理解这三大框架的协同工作,提升Java Web开发技能。而...
Struts 2+Spring 3+Hibernate框架技术精讲与整合案例Struts 2+Spring 3+Hibernate框架技术精讲与整合案例Struts 2+Spring 3+Hibernate框架技术精讲与整合案例Struts 2+Spring 3+Hibernate框架技术精讲与整合案例...