------------------------------------------------------------------ Tsysuser.java Ad0.Cn ------------------------------------------------ ------------------
程序代码 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" "" >
<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(15) 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" "" >
<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=" 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>
|