副代码:
package com.shop.dao.model;
public class Customer {
@SuppressWarnings(“unused”)
private static final long serialVersionUID = 1L;
private Long id;
private String name;
private String password;
private String realName;
private String phone;
private String email;
private String address;
private String zipCode; // 12
private String datetime;
public void setDatetime(String datetime) {
this.datetime = datetime;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRealName() {
return realName;
}
public void setRealName(String realName) {
this.realName = realName;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getDatetime() {
return datetime;
}
public String getZipCode() {
return zipCode;
}
public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}
}
customer.hbm.xml:hibernate配置文件
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE hibernate-mapping PUBLIC “-//Hibernate/Hibernate Mapping DTD 3.0//EN” “http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd” >
<hibernate-mapping>
<class name=”com.shop.dao.model.Customer” table=”bs_customer”>
<id name=”id” type=”long”>
<column name=”cust_id”></column>
<generator class=”native” />
</id>
<property name=”datetime” type=”string” insert=”false” update=”false”>
<column name=”cust_datetime” />
</property>
<property name=”name” type=”string”>
<column name=”cust_name”></column>
</property>
<property name=”password” type=”string”>
<column name=”cust_password”></column>
</property>
<property name=”realName” type=”string”>
<column name=”cust_realName”></column>
</property>
<property name=”phone” type=”string”>
<column name=”cust_phone”></column>
</property>
<property name=”email” type=”string”>
<column name=”cust_email”></column>
</property>
<property name=”address” type=”string”>
<column name=”cust_address”></column>
</property>
<property name=”zipCode” type=”string”>
<column name=”cust_zipCode”></column>
</property>
</class>
</hibernate-mapping>
DAO层:
package com.shop.dao;
import java.io.Serializable;
import java.util.List;
import com.shop.dao.model.Customer;
/*
* 用户管理
用户登录 提供用户名/密码/验证码后可以登录系统 login
用户注册 填写详细资料后成为正式注册用户 save
用户资料修改 用户登录后可以修改自己的注册资料 update
用户密码找回 忘记密码的用户可以通过email找回密码 no
//findByName 用于注册验证
* */
public interface CustomerDao {
public void save(Customer cu);
public void delete(Customer cu);
public void update(Customer cu);
public Customer get(Serializable id);
public List<Customer> list();
public Customer login(String name, String password);
public boolean findByName(String name);
}
DAOImpl层:
package com.shop.dao;
import java.io.Serializable;
import java.util.List;
import com.shop.dao.model.Customer;
/*
* 用户管理
用户登录 提供用户名/密码/验证码后可以登录系统 login
用户注册 填写详细资料后成为正式注册用户 save
用户资料修改 用户登录后可以修改自己的注册资料 update
用户密码找回 忘记密码的用户可以通过email找回密码 no
//findByName 用于注册验证
* */
public interface CustomerDao {
public void save(Customer cu);
public void delete(Customer cu);
public void update(Customer cu);
public Customer get(Serializable id);
public List<Customer> list();
public Customer login(String name, String password);
public boolean findByName(String name);
}
Service层:
package com.shop.service;
import java.io.Serializable;
import java.util.List;
import com.shop.dao.model.Customer;
public interface CustomerService {
public boolean saveRegister(Customer cu);
public void update(Customer cu);
public Customer get(Serializable id);
public List<Customer> list();
public void delete(Customer cu);
public Customer Login(String name, String password);
}
ServiceImpl层:
package com.shop.service;
import java.io.Serializable;
import java.util.List;
import com.shop.dao.model.Customer;
public interface CustomerService {
public boolean saveRegister(Customer cu);
public void update(Customer cu);
public Customer get(Serializable id);
public List<Customer> list();
public void delete(Customer cu);
public Customer Login(String name, String password);
}
Action:
package com.shop.service;
import java.io.Serializable;
import java.util.List;
import com.shop.dao.model.Customer;
public interface CustomerService {
public boolean saveRegister(Customer cu);
public void update(Customer cu);
public Customer get(Serializable id);
public List<Customer> list();
public void delete(Customer cu);
public Customer Login(String name, String password);
}
Action:
@SuppressWarnings({ “rawtypes”, “unchecked” })
public String updateList() throws Exception{
Map attibutes = ActionContext.getContext().getSession();
Long i = 31L;
attibutes.put(“CustomerUpdate”,service.get(i));
//System.out.println(getId());
cu1 = (Customer)attibutes.get(“CustomerUpdate”);
cu1.setName(getName());
/*cu1.setPassword(getPassword());*/
cu1.setAddress(getAddress());
cu1.setEmail(getEmail());
cu1.setRealName(getRealName());
cu1.setPhone(getPhone());
//cu1.setZipCode(getZipcode());
service.update(getCu1());
return SUCCESS;
}
JSP;
<%@ page language=”java” import=”java.util.*” pageEncoding=”utf-8″%>
<%@ taglib uri=”/struts-tags” prefix=”s”%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”;
%>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<base href=”<%=basePath%>”>
<title> 注册 </title>
<link rel=”stylesheet” type=”text/css” href=”jsp/images/zhuce.css”>
<meta http-equiv=”pragma” content=”no-cache”>
<meta http-equiv=”cache-control” content=”no-cache”>
<meta http-equiv=”expires” content=”0″>
<meta http-equiv=”keywords” content=”keyword1,keyword2,keyword3″>
<meta http-equiv=”description” content=”This is my page”>
</head>
<body>
<div id=”header”>
<div class=”h1″>
<div class=”logo”>
<div class=”tu”><img src=”jsp/images/l1.png”/></div>
<div class=”text”><span>宅猫购物</span></div>
</div>
<div class=”search”>
<form>
<input class=”text” type=”text”></input>
<input class=”submit” type=”submit” value=”快速搜索”></input>
</form>
</div>
</div>
<div class=”h2″>
<ul>
<li><a href=”jsp/main.jsp”>首页</a></li>
<li><a href=”#”>订购</a></li>
<li><a href=”#”>购物车</a></li>
<li><a href=”#”>服务台</a></li>
</ul>
</div>
</div>
<div id=”main”>
<div id=”left”>
<div class=”regist”>
<div class=”top”>
<ul class=”total”>
<li class=”person”>普通会员</li>
</ul>
</div>
<div class=”leg” style=”background-color:”>
<s:form action=”customerUpdate!updateList”>
<table align=”center”>
<tr>
<td>
<s:hidden name=”id” />
</td>
<td>
<s:textfield name=”name” label=”~昵称 Nickname ” style=”color:gray;” onMouseOver=”this.style.border=””1px solid #F90″”” onMouseOut=”this.style.border=””1px solid #dddddd”””/>
</td>
<td>
<s:textfield name=”realName” label=”~姓名 Name ” style=”color:gray;” onMouseOver=”this.style.border=””1px solid #F90″”” onMouseOut=”this.style.border=””1px solid #dddddd”””/>
</td>
<s:textfield name=”phone” label=”~电话 Tel ” style=”color:gray;” onMouseOver=”this.style.border=””1px solid #F90″”” onMouseOut=”this.style.border=””1px solid #dddddd”””/>
<td>
<s:textfield name=”email” label=”~邮箱 Email ” style=”color:gray;” onMouseOver=”this.style.border=””1px solid #F90″”” onMouseOut=”this.style.border=””1px solid #dddddd”””/>
</td>
<s:textfield name=”zipcode” label=”~邮编 Code ” style=”color:gray;” onMouseOver=”this.style.border=””1px solid #F90″”” onMouseOut=”this.style.border=””1px solid #dddddd”””/>
<td>
<s:textfield name=”address” label=”~地址 Address ” style=”color:gray;” onMouseOver=”this.style.border=””1px solid #F90″”” onMouseOut=”this.style.border=””1px solid #dddddd”””/>
</td>
</tr>
</table>
<center>
<input type=”submit” value=”修改”/>
</center>
</s:form>
</div>
</div>
</div>
<div id=”right”>
<div class=”r1″>
<div class=”r11″>最新公告</div>
<ul>
<li><a href=”#”>·我愿生命从容:沈奇岚宅猫独家签名本</a></li>
<li><a href=”#”>·百年老社满减钜惠满100-20 200-50</a></li>
<li><a href=”#”>·经典好书100减40 200减80 300减120</a></li>
</ul>
</div>
<div class=”r2″>
<div class=”r21″>其他商品</div>
<ul>
<li>
<a href=”#”>
<img src=”jsp/images/10.png” style=”border:1px solid black;”/>
<p>长歌行6</p>
<p>夏达 著</p>
<p>¥9.90</p>
</a>
</li>
<li>
<a href=”#”>
<img src=”jsp/images/11.png” style=”border:1px solid black;”/>
<p>父与子全集</p>
<p>(德)卜劳恩 著</p>
<p>¥17.00</p>
</a>