史上最简单的struts+spring+hibernate配置实例

<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

  本文不关心必须的JAR包,这个东东在网上能够找到很多,本文只关心如何配置,才能够让strutsspringhibernate和MYSQL相关连。

 

  ---------------------------------

  <?xmlversion="1.0"encoding="UTF-8"?>

  -//SunMicrosystems,Inc.//DTDWebApplication2.3//EN""http://java.sun.com/dtd/web-app_2_3.dtd">

 

  MVC_BPEL_MODELWeb

 

  contextConfigLocation

  /WEB-INF/hibernate_Context.xml

 

 

  springContextServlet

  org.springframework.web.context.ContextLoaderServlet

  1

 

 

  action

  org.apache.struts.action.ActionServlet

 

  config

  WEB-INF/struts-config.xml

 

 

  debug

  2

 

 

  detail

  2

 

 

  validate

  true

 

  2

 

 

  action

  *.do

 

 

  index.html

  index.htm

  index.jsp

  default.html

  default.htm

  default.jsp

 

 

  /WEB-INF/struts-bean.tld

  /WEB-INF/struts-bean.tld

 

 

  /WEB-INF/struts-html.tld

  /WEB-INF/struts-html.tld

 

 

  /WEB-INF/struts-logic.tld

  /WEB-INF/struts-logic.tld

 

 

  /WEB-INF/struts-nested.tld

  /WEB-INF/struts-nested.tld

 

 

  /WEB-INF/struts-template.tld

  /WEB-INF/struts-template.tld

 

 

  /WEB-INF/struts-tiles.tld

  /WEB-INF/struts-tiles.tld

 

 

  -----------------------------------

 

  ----------------------------------------------------------------------

  <?xmlversion="1.0"encoding="UTF-8"?>

  -//spring//DTDBEAN//EN"

  "http://www.springframework.org/dtd/spring-beans.dtd">

 

 

 

 

 

 

 

  -------------------------------------------------------------------

  <hibernate_context.xml>

  --------------------------------------------------------------------

  <?xmlversion="1.0"encoding="UTF-8"?>

  -//spring//DTDBEAN//EN""http://www.springframework.org/dtd/spring-beans.dtd">

 

 

 

 

  com.mysql.jdbc.Driver

 

 

  jdbc:mysql://localhost/pdm

 

 

  root

 

 

 

 

 

  springframework.orm.hibernate.LocalSessionFactoryBean">

 

 

 

 

 

  hbm_tb/TSysuser.hbm.xml

 

 

  hibernateProperties">

 

  hibernate.dialect">net.sf.hibernate.dialect.MySQLDialect

  hibernate.show_sql">true

 

 

 

  springframework.orm.hibernate.hibernateTransactionManager">

 

 

 

 

 

  springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">

 

 

 

 

 

  hibernateTemplate"class="org.springframework.orm.hibernate.hibernateTemplate">

 

 

 

 

 

 

 

 

  springframework.transaction.interceptor.TransactionProxyFactoryBean"id="baseTransactionProxy">

 

 

 

 

 

  PROPAGATION_REQUIRED

  PROPAGATION_REQUIRED

  PROPAGATION_REQUIRED

  PROPAGATION_REQUIRED,readOnly

 

 

 

  hibernate.UserhibernateDao">

 

 

 

 

  spring.UserManagerImpl">

 

 

 

 

  springframework.transaction.interceptor.TransactionProxyFactoryBean">

 

 

 

 

 

 

 

  true

 

 

 

  PROPAGATION_REQUIRED

  PROPAGATION_REQUIRED,readOnly

  PROPAGATION_REQUIRED,readOnly

 

 

 

 

  -------------------------------------------------------------------

  <struts-config.xml>

  -------------------------------------------------------------------

  <?xmlversion="1.0"encoding="UTF-8"?>

  A href="http://www.66of.com" target=_blank>struts-configPUBLIC"-//ApacheSoftwareFoundation//DTDstrutsConfiguration1.1//EN"

  "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

  <struts-config>

 

 

 

 

  struts.validator.DynaValidatorForm">

 

 

 

 

 

 

 

 

 

  springframework.web.struts.DelegatingActionProxy"name="UserActionForm"scope="request"parameter="method"validate="false">

 

 

 

 

 

 

  springframework.web.struts.ContextLoaderPlugIn">

 

 

  struts-config>

  ------------------------------------------------------------------

  UserhibernateDao.java

  ------------------------------------------------------------------

  /*

  *创建日期2005-4-7

  *

  *更改所生成文件模板为

  *窗口>首选项>Java>代码生成>代码和注释

  */

  packagecom.yaya.service.dao.hibernate;

  importjava.util.List;

  importorg.springframework.orm.ObjectRetrievalFailureException;

  importorg.springframework.orm.hibernate.support.hibernateDaoSupport;

  importcom.yaya.hb.TSysuser;

  importcom.yaya.service.dao.IUserDao;

  importjava.util.List;

  importorg.apache.commons.logging.Log;

  importorg.apache.commons.logging.LogFactory;

  /**

  *@authorAdministrator

  *

  *更改所生成类型注释的模板为

  *窗口>首选项>Java>代码生成>代码和注释

  */

  publicclassUserhibernateDaoextendshibernateDaoSupportimplementsIUserDao{

  privateLoglog=LogFactory.getLog(UserhibernateDao.class);

  /*(非Javadoc)

  *@seecom.jandar.dao.IUserDAO#getUsers()

  */

  publicListgetUsers(){

  returngethibernateTemplate().find("fromTSysuser");

  }

  /*(非Javadoc)

  *@seecom.jandar.dao.IUserDAO#getUser(java.lang.Long)

  */

  publicTSysusergetUser(Stringusername){

  //TODO自动生成方法存根

  //Stringmsg=gethibernateTemplate().get(TSysuser.class,username).toString();

  TSysuseruser=(TSysuser)gethibernateTemplate().get(TSysuser.class,username);

  //TSysuseruser=(TSysuser)gethibernateTemplate().find("fromTSysuserwhereusername=?",username);

  System.out.println(user.getUserdesc());

  System.out.println(user.getHeadship());

  if(user==null){

  thrownewObjectRetrievalFailureException(TSysuser.class,username);

  }

  returnuser;

  }

  /*(非Javadoc)

  *@seecom.jandar.dao.IUserDAO#saveUser(com.jandar.model.User)

  */

  publicvoidsaveUser(TSysuseruser){

  log.debug("xxxxxxx");

  System.out.println("yyyy");

  gethibernateTemplate().saveOrUpdate(user);

  if(log.isDebugEnabled()){

  log.debug("usernamesetto"+user.getUsername());

  }

  }

  /*(非Javadoc)

  *@seecom.jandar.dao.IUserDAO#removeUser(java.lang.Long)

  */

  publicvoidremoveUser(Stringusername){

  Objectuser=gethibernateTemplate().load(TSysuser.class,username);

  gethibernateTemplate().delete(user);

  if(log.isDebugEnabled()){

  log.debug("deluser"+username);

  }

  }

  }

  -------------------------------------------------------------------

  useraction.java

  --------------------------------------------------------------------

  /*

  *创建日期2005-4-11

  *

  *更改所生成文件模板为

  *窗口>首选项>Java>代码生成>代码和注释

  */

  packagecom.yaya.action;

  importjava.util.Date;

  importorg.apache.struts.actions.DispatchAction;

  importjavax.servlet.http.HttpServletRequest;

  importjavax.servlet.http.HttpServletResponse;

  importorg.apache.commons.beanutils.ConvertUtils;

  importorg.apache.commons.beanutils.locale.converters.DateLocaleConverter;

  importorg.apache.commons.logging.Log;

  importorg.apache.commons.logging.LogFactory;

  importorg.apache.struts.action.ActionErrors;

  importorg.apache.struts.action.ActionForm;

  importorg.apache.struts.action.ActionForward;

  importorg.apache.struts.action.ActionMapping;

  importorg.apache.struts.action.ActionMessage;

  importorg.apache.struts.action.ActionMessages;

  importorg.apache.struts.action.DynaActionForm;

  importorg.apache.struts.util.MessageResources;

  importcom.yaya.hb.TSysuser;

  importcom.yaya.service.spring.UserManagerImpl;

  /**

  *@authorAdministrator

  *

  *更改所生成类型注释的模板为

  *窗口>首选项>Java>代码生成>代码和注释

  */

  publicclassUserActionextendsDispatchAction{

  privatestaticLoglog=LogFactory.getLog(UserAction.class);

  privateUserManagerImplmgr=null;

  publicvoidsetUserManager(UserManagerImpluserManager){

  this.mgr=userManager;

  }

  publicActionForwarddelete(

  ActionMappingmapping,

  ActionFormform,

  HttpServletRequestrequest,

  HttpServletResponseresponse)

  throwsException{

  if(log.isDebugEnabled()){

  log.debug("entering'delete'method...");

  }

  mgr.removeUser(request.getParameter("user.username"));

  ActionMessagesmessages=newActionMessages();

  messages.add(

  ActionMessages.GLOBAL_MESSAGE,

  newActionMessage("user.deleted"));

  saveMessages(request,messages);

  returnlist(mapping,form,request,response);

  }

  publicActionForwardedit(

  ActionMappingmapping,

  ActionFormform,

  HttpServletRequestrequest,

  HttpServletResponseresponse)

  throwsException{

  if(log.isDebugEnabled()){

  log.debug("entering'edit'method...");

  }

  DynaActionFormuserForm=(DynaActionForm)form;

  Stringusername=request.getParameter("username");

  //nulluserIdindicatesanadd

  if(username!=null){

  try

  {

  TSysuseruser=mgr.getUser(username);

  if(user==null){

  ActionMessageserrors=newActionMessages();

  errors.add(

  ActionMessages.GLOBAL_MESSAGE,

  newActionMessage("user.missing"));

  saveErrors(request,(ActionErrors)errors);

  returnmapping.findForward("list");

  }

  userForm.set("user",user);

  request.setAttribute("user",user);

  }

  catch(Exceptione)

  {

  e.printStackTrace();

  }

  }

  returnmapping.findForward("edit");

  }

  publicActionForwardlist(

  ActionMappingmapping,

  ActionFormform,

  HttpServletRequestrequest,

  HttpServletResponseresponse)

  throwsException{

  if(log.isDebugEnabled()){

  log.debug("entering'list'method...");

  }

  request.setAttribute("users",mgr.getUsers());

  returnmapping.findForward("list");

  }

  publicActionForwardsave(

  ActionMappingmapping,

  ActionFormform,

  HttpServletRequestrequest,

  HttpServletResponseresponse)

  throwsException{

  if(log.isDebugEnabled()){

  log.debug("entering'save'method...");

  }

  if(isCancelled(request)){

  returnlist(mapping,form,request,response);

  }

  //runvalidationrulesonthisform

  ActionMessageserrors=form.validate(mapping,request);

  if(!errors.isEmpty()){

  saveErrors(request,(ActionErrors)errors);

  returnmapping.findForward("edit");

  }

  DynaActionFormuserForm=(DynaActionForm)form;

  TSysuseruser=(TSysuser)userForm.get("username");

  mgr.saveUser(user);

  ActionMessagesmessages=newActionMessages();

  messages.add(ActionMessages.GLOBAL_MESSAGE,

  newActionMessage("user.saved",user.getUsername()));

  saveMessages((HttpServletRequest)request.getSession(),messages);

  returnmapping.findForward("users");

  }

  publicActionForwardunspecified(

  ActionMappingmapping,

  ActionFormform,

  HttpServletRequestrequest,

  HttpServletResponseresponse)

  throwsException{

  returnlist(mapping,form,request,response);

  }

  }

  -------------------------------------------------------------------

  UserMenuActionForm.java

  -------------------------------------------------------------------

  /*

  *创建日期2005-3-28

  *

  *更改所生成文件模板为

  *窗口>首选项>Java>代码生成>代码和注释

  */

  packagecom.yaya.actionform;

  importjava.sql.Date;

  importorg.apache.struts.action.ActionForm;

  /**

  *@authorAdministrator

  *

  *更改所生成类型注释的模板为

  *窗口>首选项>Java>代码生成>代码和注释

  */

  publicclassUserMenuActionFormextendsActionForm{

  /**identifierfield*/

  privateStringusername;

  /**identifierfield*/

  privateStringfitemcode;

  /**identifierfield*/

  privateStringitemcode;

  /**identifierfield*/

  privateStringitemdesc;

  /**identifierfield*/

  privateStringitemtype;

  /**identifierfield*/

  privateIntegeritemid;

  /**identifierfield*/

  privateStringlastmodif;

  /**identifierfield*/

  privateDatelastmdate;

  /**identifierfield*/

  privateStringcreadtor;

  /**identifierfield*/

  privateDatecreatdate;

  /**identifierfield*/

  privateStringtitle;

  /**identifierfield*/

  privateStringurl;

  /**identifierfield*/

  privateStringtarget;

  /**identifierfield*/

  privateStringicon;

  /**identifierfield*/

  privateStringiconopen;

  /**identifierfield*/

  privateIntegeropen;

  /**identifierfield*/

  privateIntegerid;

  /**identifierfield*/

  privateIntegerpid;

  publicStringgetUsername(){

  returnthis.username;

  }

  publicvoidsetUsername(Stringusername){

  this.username=username;

  }

  publicStringgetFitemcode(){

  returnthis.fitemcode;

  }

  publicvoidsetFitemcode(Stringfitemcode){

  this.fitemcode=fitemcode;

  }

  publicStringgetItemcode(){

  returnthis.itemcode;

  }

  publicvoidsetItemcode(Stringitemcode){

  this.itemcode=itemcode;

  }

  publicStringgetItemdesc(){

  returnthis.itemdesc;

  }

  publicvoidsetItemdesc(Stringitemdesc){

  this.itemdesc=itemdesc;

  }

  publicStringgetItemtype(){

  returnthis.itemtype;

  }

  publicvoidsetItemtype(Stringitemtype){

  this.itemtype=itemtype;

  }

  publicIntegergetItemid(){

  returnthis.itemid;

  }

  publicvoidsetItemid(Integeritemid){

  this.itemid=itemid;

  }

  publicStringgetLastmodif(){

  returnthis.lastmodif;

  }

  publicvoidsetLastmodif(Stringlastmodif){

  this.lastmodif=lastmodif;

  }

  publicDategetLastmdate(){

  returnthis.lastmdate;

  }

  publicvoidsetLastmdate(Datelastmdate){

  this.lastmdate=lastmdate;

  }

  publicStringgetCreadtor(){

  returnthis.creadtor;

  }

  publicvoidsetCreadtor(Stringcreadtor){

  this.creadtor=creadtor;

  }

  publicDategetCreatdate(){

  returnthis.creatdate;

  }

  publicvoidsetCreatdate(Datecreatdate){

  this.creatdate=creatdate;

  }

  publicStringgetTitle(){

  returnthis.title;

  }

  publicvoidsetTitle(Stringtitle){

  this.title=title;

  }

  publicStringgetUrl(){

  returnthis.url;

  }

  publicvoidsetUrl(Stringurl){

  this.url=url;

  }

  publicStringgetTarget(){

  returnthis.target;

  }

  publicvoidsetTarget(Stringtarget){

  this.target=target;

  }

  publicStringgetIcon(){

  returnthis.icon;

  }

  publicvoidsetIcon(Stringicon){

  this.icon=icon;

  }

  publicStringgetIconopen(){

  returnthis.iconopen;

  }

  publicvoidsetIconopen(Stringiconopen){

  this.iconopen=iconopen;

  }

  publicIntegergetOpen(){

  returnthis.open;

  }

  publicvoidsetOpen(Integeropen){

  this.open=open;

  }

  publicIntegergetId(){

  returnthis.id;

  }

  publicvoidsetId(Integerid){

  this.id=id;

  }

  publicIntegergetPid(){

  returnthis.pid;

  }

  publicvoidsetPid(Integerpid){

  this.pid=pid;

  }

  }

  ------------------------------------------------------------------

  packagecom.yaya.hb;

  importjava.io.InputStream;

  importjava.io.Serializable;

  importjava.util.Date;

  importorg.apache.commons.lang.builder.EqualsBuilder;

  importorg.apache.commons.lang.builder.HashCodeBuilder;

  importorg.apache.commons.lang.builder.ToStringBuilder;

  /**@authorhibernateCodeGenerator*/

  publicclassTSysuserimplementsSerializable{

  /**identifierfield*/

  privateStringusername;

  /**identifierfield*/

  privateStringuserdesc;

  /**identifierfield*/

  privateStringpasswords;

  /**identifierfield*/

  privateStringdeptno;

  /**identifierfield*/

  privateStringheadship;

  /**identifierfield*/

  privateStringsex;

  /**identifierfield*/

  privateStringtel;

  /**identifierfield*/

  privateStringemail;

  /**identifierfield*/

  privateStringurl;

  /**identifierfield*/

  privateStringpcall;

  /**identifierfield*/

  /**identifierfield*/

  privateStringuserphoto;

  /**identifierfield*/

  privateIntegerfacerefutime;

  /**identifierfield*/

  privateStringfacelanguage;

  /**identifierfield*/

  privateStringlastmodif;

  /**identifierfield*/

  privateDatelastmdate;

  /**identifierfield*/

  privateStringcreadtor;

  /**identifierfield*/

  privateDatecreatdate;

  /**fullconstructor*/

  publicTSysuser(Stringusername,Stringuserdesc,Stringpasswords,Stringdeptno,Stringheadship,Stringsex,Stringtel,Stringemail,Stringurl,Stringpcall,InputStreamuserimage,Stringuserphoto,Integerfacerefutime,Stringfacelanguage,Stringlastmodif,Datelastmdate,Stringcreadtor,Datecreatdate){

  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;

  }

  /**defaultconstructor*/

  publicTSysuser(){

  }

  publicStringgetUsername(){

  returnthis.username;

  }

  publicvoidsetUsername(Stringusername){

  this.username=username;

  }

  publicStringgetUserdesc(){

  returnthis.userdesc;

  }

  publicvoidsetUserdesc(Stringuserdesc){

  this.userdesc=userdesc;

  }

  publicStringgetPasswords(){

  returnthis.passwords;

  }

  publicvoidsetPasswords(Stringpasswords){

  this.passwords=passwords;

  }

  publicStringgetDeptno(){

  returnthis.deptno;

  }

  publicvoidsetDeptno(Stringdeptno){

  this.deptno=deptno;

  }

  publicStringgetHeadship(){

  returnthis.headship;

  }

  publicvoidsetHeadship(Stringheadship){

  this.headship=headship;

  }

  publicStringgetSex(){

  returnthis.sex;

  }

  publicvoidsetSex(Stringsex){

  this.sex=sex;

  }

  publicStringgetTel(){

  returnthis.tel;

  }

  publicvoidsetTel(Stringtel){

  this.tel=tel;

  }

  publicStringgetEmail(){

  returnthis.email;

  }

  publicvoidsetEmail(Stringemail){

  this.email=email;

  }

  publicStringgetUrl(){

  returnthis.url;

  }

  publicvoidsetUrl(Stringurl){

  this.url=url;

  }

  publicStringgetPcall(){

  returnthis.pcall;

  }

  publicvoidsetPcall(Stringpcall){

  this.pcall=pcall;

  }

  publicStringgetUserphoto(){

  returnthis.userphoto;

  }

  publicvoidsetUserphoto(Stringuserphoto){

  this.userphoto=userphoto;

  }

  publicIntegergetFacerefutime(){

  returnthis.facerefutime;

  }

  publicvoidsetFacerefutime(Integerfacerefutime){

  this.facerefutime=facerefutime;

  }

  publicStringgetFacelanguage(){

  returnthis.facelanguage;

  }

  publicvoidsetFacelanguage(Stringfacelanguage){

  this.facelanguage=facelanguage;

  }

  publicStringgetLastmodif(){

  returnthis.lastmodif;

  }

  publicvoidsetLastmodif(Stringlastmodif){

  this.lastmodif=lastmodif;

  }

  publicDategetLastmdate(){

  returnthis.lastmdate;

  }

  publicvoidsetLastmdate(Datelastmdate){

  this.lastmdate=lastmdate;

  }

  publicStringgetCreadtor(){

  returnthis.creadtor;

  }

  publicvoidsetCreadtor(Stringcreadtor){

  this.creadtor=creadtor;

  }

  publicDategetCreatdate(){

  returnthis.creatdate;

  }

  publicvoidsetCreatdate(Datecreatdate){

  this.creatdate=creatdate;

  }

  publicStringtoString(){

  returnnewToStringBuilder(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();

  }

  publicbooleanequals(Objectother){

  if(!(otherinstanceofTSysuser))returnfalse;

  TSysusercastOther=(TSysuser)other;

  returnnewEqualsBuilder()

  .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();

  }

  publicinthashCode(){

  returnnewHashCodeBuilder()

  .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();

  }

  }

  ---------------------------------------------------------------------

  /*

  *创建日期2005-4-11

  *

  *更改所生成文件模板为

  *窗口>首选项>Java>代码生成>代码和注释

  */

  packagecom.yaya.service;

  importjava.util.List;

  importcom.yaya.hb.TSysuser;

  importcom.yaya.service.dao.IUserDao;

  /**

  *@authorAdministrator

  *

  *更改所生成类型注释的模板为

  *窗口>首选项>Java>代码生成>代码和注释

  */

  publicinterfaceIUserManager{

  publicvoidsetUserDAO(IUserDaodao);

  publicTSysusergetUser(Stringusername);

  publicListgetUsers();

  publicTSysusersaveUser(TSysuseruser);

  publicvoidremoveUser(Stringusername);

  }

  --------------------------------------------------------------------

  /*

  *创建日期2005-4-7

  *

  *更改所生成文件模板为

  *窗口>首选项>Java>代码生成>代码和注释

  */

  packagecom.yaya.service.dao;

  /**

  *@authorAdministrator

  *

  *更改所生成类型注释的模板为

  *窗口>首选项>Java>代码生成>代码和注释

  */

  publicinterfaceIDAO{

  }

  --------------------------------------------------------------

  /*

  *创建日期2005-4-11

  *

  *更改所生成文件模板为

  *窗口>首选项>Java>代码生成>代码和注释

  */

  packagecom.yaya.service.dao;

  importjava.util.List;

  importcom.yaya.hb.TSysuser;

  /**

  *@authorAdministrator

  *

  *更改所生成类型注释的模板为

  *窗口>首选项>Java>代码生成>代码和注释

  */

  publicinterfaceIUserDaoextendsIDAO{

  publicListgetUsers();

  publicTSysusergetUser(Stringusername);

  publicvoidsaveUser(TSysuseruser);

  publicvoidremoveUser(Stringusername);

  }

  ----------------------------------------------------------

  /*

  *创建日期2005-4-11

  *

  *更改所生成文件模板为

  *窗口>首选项>Java>代码生成>代码和注释

  */

  packagecom.yaya.service.spring;

  importcom.yaya.hb.TSysuser;

  importcom.yaya.service.IUserManager;

  importcom.yaya.service.dao.IUserDao;

  importjava.util.List;

  importorg.apache.commons.logging.Log;

  importorg.apache.commons.logging.LogFactory;

  /**

  *@authorAdministrator

  *

  *更改所生成类型注释的模板为

  *窗口>首选项>Java>代码生成>代码和注释

  */

  publicclassUserManagerImplimplementsIUserManager{

  privatestaticLoglog=LogFactory.getLog(UserManagerImpl.class);

  publicIUserDaouserDao;

  /**

  *@return返回userDao。

  */

  publicvoidsetUserDAO(IUserDaodao){

  this.userDao=dao;

  }

  publicIUserDaogetUserDao(){

  returnuserDao;

  }

  /**

  *@paramuserDao要设置的userDao。

  */

  publicvoidsetUserDao(IUserDaouserDao){

  this.userDao=userDao;

  }

  publicTSysusergetUser(Stringusername){

  try

  {

  TSysuseruser=userDao.getUser(username);

  returnuser;

  }

  catch(Exceptione)

  {

  e.printStackTrace();

  }

  returnuserDao.getUser(username);

  }

  /*(非Javadoc)

  *@seecom.jandar.service.IUserManager#getUsers()

  */

  publicListgetUsers(){

  //TODO自动生成方法存根

  returnuserDao.getUsers();

  }

  /*(非Javadoc)

  *@seecom.jandar.service.IUserManager#saveUser(com.jandar.model.User)

  */

  publicTSysusersaveUser(TSysuseruser){

  //TODO自动生成方法存根

  userDao.saveUser(user);

  returnuser;

  }

  /*(非Javadoc)

  *@seecom.jandar.service.IUserManager#removeUser(java.lang.String)

  */

  publicvoidremoveUser(Stringusername){

  //TODO自动生成方法存根

  userDao.removeUser(username);

  }<

<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
阅读更多
个人分类: xml ajax
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭