day6javascript
1.模塊分析css
案例1-按照狀態查詢訂單列表
需求: 在left.jsp上有一個訂單管理,下面有5個鏈接,點擊每一個鏈接顯示當前狀態全部訂單
步驟分析:
1.修改left.jsp,添加5個鏈接 /store/adminOrder?method=findAllByState&state=x
2.編寫adminorderservlet,繼承baseservlet,編寫findAllByState方法
獲取state
調用service獲取列表
請求轉發到 /admin/order/list.jsp
3.dao中 判斷state,發送不一樣的sql便可html
案例2-查詢訂單的詳情
需求:
在list.jsp上點擊每個訂單的 "訂單詳情" 將該訂單的訂單項列表展現出來
技術分析: ajaxjava
layer使用說明:
一、使用時,請把文件夾layer整個放置在您站點的任何一個目錄,在頁面上只需引入layer.js便可
二、jquery需使用1.8以上的版本,先導入jquery的js,再導入layer.js
三、更多使用說明與演示,請參見layer官網。node
例如:mysql
$(function(){
$("#btn11").click(function(){
layer.open({
type: 1,//0:信息框; 1:頁面; 2:iframe層; 3:加載層; 4:tip層
title:"我自信,我驕傲!",//標題
area: ['400px', '300px'],//大小
shadeClose: true, //點擊彈層外區域 遮罩關閉
content: '一員'//內容
});
});jquery
步驟分析:
1.給 "訂單詳情" 添加單擊事件 攜帶oid
2.編寫函數
$.post(url,params,fn,type);
url:/store/adminOrder
params:{method:showDetail,oid:xxx}
fn:展現
type:json
3.編寫showDetail方法
獲取oid
調用service中的getById() .獲取order,獲取order的訂單項列表
將list轉成json返回給瀏覽器linux
案例3-修改訂單的狀態
需求:
在已付款的訂單列表,點擊"去發貨",修改訂單的狀態爲2
步驟分析:
1.修改list.jsp,給 "去發貨"添加鏈接,
/store/adminOrder?method=updateState&oid=xxx
2.在adminorderservlet中 編寫updateState
獲取oid
調用service 獲取order,設置state=2 更新order
重定向到 已付款訂單列表中程序員
案例4--部署應用商城項目
部署環境: linux操做系統 安裝jdk 、安裝tomcat 、 安裝mysql 、 安裝redis
需求:
將咱們本身的項目(應用)發佈到linux下的tomcat中
技術分析:
項目打包(war包) 數據備份還原
項目打包: 後綴名: .war
特色: 在tomcat的webapps目錄下,隨着服務器的啓動而解壓
打包方式:
方式1:經過ide工具 ★ 在項目右鍵-->export-->搜索 war -->選擇目的地
方式2:手動打包 在項目目錄右鍵-->添加到壓縮文件(zip),-->修改後綴名爲.war便可
數據備份還原 mysql備份:
方式1:命令 在cmd窗口
mysqldump -uroot -p密碼 要備份的數據庫名稱>文件磁盤位置
例如; mysqldump -uroot -p1234 store38>g:\store38.sql
方式2:工具 不說了web
數據備份mysql還原:
方式1:命令
方式a: 在cmd窗口中(前提:手動建立數據庫)
mysql -uroot -p密碼 目的地數據庫<文件磁盤位置
例如: mysql -uroot -p1234 store381<g:\store38.sql
方式b: 先登陸到目的地數據庫中 source 文件磁盤位置
例如: source g:\store38.sql
方式2:工具
步驟:
1.將war和sql上傳到linux
2.將war包放入tomcat的webapps目錄下
3.還原sql
linux指令 : service mysql status #查詢mysql的運行狀態
service mysql start #啓動mysql
4.啓動tomcat
進入tomcat/bin目錄 linux指令 : sh startup.sh
5.啓動redis linux指令 : ps -ef|grep redis
進入redis的目錄 /usr/local/redis/bin
linux指令 : ./redis-server redis.conf
注意: 中文亂碼
在鏈接的url後面追加: ?useUnicode=true&characterEncoding=utf-8
注意:若配置文件爲xml的時候,特殊字符必須轉義 & &
擴展-第一次訪問慢:
linux命令
hostname #查看主機名
vi /etc/hosts #修改本地dns配置
在127.0.0.1 最後加上 " 本身的主機名"
擴展:爲全部的dao中的save方法添加一段代碼
補充 動態代理:
步驟:
1.判斷是否dao,如果dao才建立代理對象
2.判斷是不是save方法,如果save方法
打印一句話,而後執行原來邏輯
aop:面向切面編程
ioc:控制反轉(解耦合)
2.代碼區
com.itheima.constant
package com.itheima.constant; public interface Constant { /** * 用戶未激活 */ int USER_IS_NOT_ACTIVE = 0; /** * 用戶已激活 */ int USER_IS_ACTIVE = 1; /** * 記住用戶名 */ String SAVE_NAME ="ok"; /** * redis中存儲分類列表的key */ String STORE_CATEGORY_LIST="STORE_CATEGORY_LIST"; /** * redis的服務器地址 */ String REDIS_HOST = "192.168.17.136"; /** * redis的服務器端口號 */ int REDIS_PORT = 6379; /** * 熱門商品 */ int PRODUCT_IS_HOT = 1; /** * 商品未下架 */ int PRODUCT_IS_UP = 0; /** * 商品已下架 */ int PRODUCT_IS_DOWN = 1; /** * 訂單狀態 未付款 */ int ORDER_WEIFUKUAN=0; /** * 訂單狀態 已付款 */ int ORDER_YIFUKUAN=1; /** * 訂單狀態 已發貨 */ int ORDER_YIFAHUO=2; /** * 訂單狀態 已完成 */ int ORDER_YIWANCHENG=3; }
com.itheima.dao
package com.itheima.dao; import java.util.List; import com.itheima.domain.Category; public interface CategoryDao { List<Category> findAll() throws Exception; void save(Category c) throws Exception; }
package com.itheima.dao; import java.util.List; import com.itheima.domain.Order; import com.itheima.domain.OrderItem; import com.itheima.domain.PageBean; public interface OrderDao { void save(Order order) throws Exception; void saveItem(OrderItem oi) throws Exception; int getTotalRecord(String uid) throws Exception; List<Order> findMyOrdersByPage(PageBean<Order> pb, String uid) throws Exception; Order getById(String oid) throws Exception; void update(Order order) throws Exception; List<Order> findAllByState(String state) throws Exception; }
package com.itheima.dao; import java.util.List; import com.itheima.domain.PageBean; import com.itheima.domain.Product; public interface ProductDao { List<Product> findHot() throws Exception; List<Product> findNew() throws Exception; Product getById(String pid) throws Exception; List<Product> findByPage(PageBean<Product> pb, String cid) throws Exception; int getTotalRecord(String cid) throws Exception; List<Product> findAll() throws Exception; void save(Product p) throws Exception; }
package com.itheima.dao; import com.itheima.domain.User; public interface UserDao { void save(User user) throws Exception; User getByCode(String code) throws Exception; void update(User user) throws Exception; User getByUsernameAndPwd(String username, String password) throws Exception; }
com.itheima.dao.impl
package com.itheima.dao.impl; import java.util.List; import org.apache.commons.dbutils.QueryRunner; import org.apache.commons.dbutils.handlers.BeanListHandler; import com.itheima.dao.CategoryDao; import com.itheima.domain.Category; import com.itheima.utils.DataSourceUtils; public class CategoryDaoImpl implements CategoryDao { @Override /** * 查詢全部分類 */ public List<Category> findAll() throws Exception { QueryRunner qr = new QueryRunner(DataSourceUtils.getDataSource()); String sql = "select * from category"; return qr.query(sql, new BeanListHandler<>(Category.class)); } @Override /** * 添加分類 */ public void save(Category c) throws Exception { QueryRunner qr = new QueryRunner(DataSourceUtils.getDataSource()); String sql = "insert into category values (?,?);"; qr.update(sql, c.getCid(),c.getCname()); } }
package com.itheima.dao.impl; import java.util.List; import java.util.Map; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.dbutils.QueryRunner; import org.apache.commons.dbutils.handlers.BeanHandler; import org.apache.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.MapListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import com.itheima.dao.OrderDao; import com.itheima.domain.Order; import com.itheima.domain.OrderItem; import com.itheima.domain.PageBean; import com.itheima.domain.Product; import com.itheima.utils.DataSourceUtils; public class OrderDaoImpl implements OrderDao { @Override /** * 保存訂單 */ public void save(Order o) throws Exception { QueryRunner qr = new QueryRunner(); /** * `oid` varchar(32) NOT NULL, `ordertime` datetime DEFAULT NULL, `total` double DEFAULT NULL, `state` int(11) DEFAULT NULL, `address` varchar(30) DEFAULT NULL, `name` varchar(20) DEFAULT NULL, `telephone` varchar(20) DEFAULT NULL, `uid` varchar(32) DEFAULT NULL, */ String sql = "insert into orders values(?,?,?,?,?,?,?,?)"; qr.update(DataSourceUtils.getConnection(), sql, o.getOid(),o.getOrdertime(),o.getTotal(), o.getState(),o.getAddress(),o.getName(), o.getTelephone(),o.getUser().getUid()); } @Override /** * 保存訂單項 */ public void saveItem(OrderItem oi) throws Exception { QueryRunner qr = new QueryRunner(); /* * `itemid` varchar(32) NOT NULL, `count` int(11) DEFAULT NULL, `subtotal` double DEFAULT NULL, `pid` varchar(32) DEFAULT NULL, `oid` varchar(32) DEFAULT NULL, */ String sql = "insert into orderitem values(?,?,?,?,?)"; qr.update(DataSourceUtils.getConnection(), sql, oi.getItemid(),oi.getCount(),oi.getSubtotal(), oi.getProduct().getPid(),oi.getOrder().getOid()); } @Override /** * 獲取個人訂單的總條數 */ public int getTotalRecord(String uid) throws Exception { QueryRunner qr = new QueryRunner(DataSourceUtils.getDataSource()); String sql = "select count(*) from orders where uid = ?"; return ((Long)qr.query(sql, new ScalarHandler(), uid)).intValue(); } @Override /** * 獲取個人訂單 當前頁數據 */ public List<Order> findMyOrdersByPage(PageBean<Order> pb, String uid) throws Exception { QueryRunner qr = new QueryRunner(DataSourceUtils.getDataSource()); //查詢全部訂單(基本信息) String sql="select * from orders where uid = ? order by ordertime desc limit ?,?"; List<Order> list = qr.query(sql, new BeanListHandler<>(Order.class), uid,pb.getStartIndex(),pb.getPageSize()); //遍歷訂單集合 獲取每個訂單,查詢每一個訂單訂單項 for (Order order : list) { sql="SELECT * FROM orderitem oi,product p WHERE oi.pid = p.pid AND oi.oid = ?"; List<Map<String, Object>> maplist = qr.query(sql, new MapListHandler(), order.getOid()); //遍歷maplist 獲取每個訂單項詳情,封裝成orderitem,將其加入當前訂單的訂單項列表中 for (Map<String, Object> map : maplist) { //1.封裝成orderitem //a.建立orderitem OrderItem oi = new OrderItem(); //b.封裝orderitem BeanUtils.populate(oi, map); //c.手動封裝product Product p = new Product(); BeanUtils.populate(p, map); oi.setProduct(p); //2.將orderitem放入order的訂單項列表 order.getItems().add(oi); } } return list; } @Override /** * 訂單詳情 */ public Order getById(String oid) throws Exception { //1.查詢訂單基本信息 QueryRunner qr = new QueryRunner(DataSourceUtils.getDataSource()); String sql ="select * from orders where oid = ?"; Order order = qr.query(sql, new BeanHandler<>(Order.class), oid); //2.查詢訂單項 sql ="SELECT * FROM orderitem oi,product p WHERE oi.pid = p.pid AND oi.oid = ?"; //全部的訂單項詳情 List<Map<String, Object>> maplist = qr.query(sql, new MapListHandler(), oid); //遍歷 獲取每個訂單項詳情 封裝成orderitem 加入到當前訂單的items中 for (Map<String, Object> map : maplist) { //建立ordreitem OrderItem oi = new OrderItem(); //封裝 BeanUtils.populate(oi, map); //手動封裝product Product p = new Product(); BeanUtils.populate(p, map); oi.setProduct(p); //將orderitem加入到訂單的items中 order.getItems().add(oi); } return order; } @Override public void update(Order order) throws Exception { QueryRunner qr = new QueryRunner(DataSourceUtils.getDataSource()); /** * `oid` varchar(32) NOT NULL, `ordertime` datetime DEFAULT NULL, `total` double DEFAULT NULL, `state` int(11) DEFAULT NULL, `address` varchar(30) DEFAULT NULL, `name` varchar(20) DEFAULT NULL, `telephone` varchar(20) DEFAULT NULL, `uid` varchar(32) DEFAULT NULL, */ String sql="update orders set state = ?,address = ?,name =?,telephone = ? where oid = ?"; qr.update(sql,order.getState(),order.getAddress(),order.getName(), order.getTelephone(),order.getOid()); } @Override /** * 後臺查詢訂單列表 */ public List<Order> findAllByState(String state) throws Exception { QueryRunner qr = new QueryRunner(DataSourceUtils.getDataSource()); String sql = "select * from orders "; //判斷state是否爲空 if(null==state || state.trim().length()==0){ sql +=" order by ordertime desc"; return qr.query(sql, new BeanListHandler<>(Order.class)); } sql += " where state = ? order by ordertime desc"; return qr.query(sql, new BeanListHandler<>(Order.class),state); } }
package com.itheima.dao.impl; import java.util.List; import org.apache.commons.dbutils.QueryRunner; import org.apache.commons.dbutils.handlers.BeanHandler; import org.apache.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import com.itheima.constant.Constant; import com.itheima.dao.ProductDao; import com.itheima.domain.PageBean; import com.itheima.domain.Product; import com.itheima.utils.DataSourceUtils; public class ProductDaoImpl implements ProductDao { @Override /** * 查詢熱門 */ public List<Product> findHot() throws Exception { QueryRunner qr = new QueryRunner(DataSourceUtils.getDataSource()); String sql = "select * from product where is_hot = ? and pflag = ? order by pdate desc limit 9"; return qr.query(sql, new BeanListHandler<>(Product.class), Constant.PRODUCT_IS_HOT,Constant.PRODUCT_IS_UP); } @Override /** * 查詢最新 */ public List<Product> findNew() throws Exception { QueryRunner qr = new QueryRunner(DataSourceUtils.getDataSource()); String sql = "select * from product where pflag = ? order by pdate desc limit 9"; return qr.query(sql, new BeanListHandler<>(Product.class),Constant.PRODUCT_IS_UP); } @Override /** * 查詢單個商品 */ public Product getById(String pid) throws Exception { QueryRunner qr = new QueryRunner(DataSourceUtils.getDataSource()); String sql = "select * from product where pid = ? limit 1"; return qr.query(sql, new BeanHandler<>(Product.class), pid); } @Override /** * 查詢當前頁數據 */ public List<Product> findByPage(PageBean<Product> pb, String cid) throws Exception { QueryRunner qr = new QueryRunner(DataSourceUtils.getDataSource()); String sql = "select * from product where cid = ? and pflag = ? order by pdate desc limit ?,?"; return qr.query(sql, new BeanListHandler<>(Product.class), cid,Constant.PRODUCT_IS_UP,pb.getStartIndex(),pb.getPageSize()); } @Override /** * 獲取總記錄數 */ public int getTotalRecord(String cid) throws Exception { return ((Long)new QueryRunner(DataSourceUtils.getDataSource()).query("select count(*) from product where cid = ? and pflag = ?", new ScalarHandler(), cid,Constant.PRODUCT_IS_UP)).intValue(); } @Override /** * 後臺展現上架商品 */ public List<Product> findAll() throws Exception { QueryRunner qr = new QueryRunner(DataSourceUtils.getDataSource()); String sql = "select * from product where pflag = ? order by pdate desc"; return qr.query(sql, new BeanListHandler<>(Product.class), Constant.PRODUCT_IS_UP); } @Override /** * 保存商品 */ public void save(Product p) throws Exception { QueryRunner qr = new QueryRunner(DataSourceUtils.getDataSource()); /* * `pid` varchar(32) NOT NULL, `pname` varchar(50) DEFAULT NULL, `market_price` double DEFAULT NULL, `shop_price` double DEFAULT NULL, `pimage` varchar(200) DEFAULT NULL, `pdate` date DEFAULT NULL, `is_hot` int(11) DEFAULT NULL, `pdesc` varchar(255) DEFAULT NULL, `pflag` int(11) DEFAULT NULL, `cid` varchar(32) DEFAULT NULL, */ String sql="insert into product values(?,?,?,?,?,?,?,?,?,?);"; qr.update(sql, p.getPid(),p.getPname(),p.getMarket_price(), p.getShop_price(),p.getPimage(),p.getPdate(), p.getIs_hot(),p.getPdesc(),p.getPflag(), p.getCategory().getCid()); } }
package com.itheima.dao.impl; import java.sql.SQLException; import org.apache.commons.dbutils.QueryRunner; import org.apache.commons.dbutils.handlers.BeanHandler; import com.itheima.dao.UserDao; import com.itheima.domain.User; import com.itheima.utils.DataSourceUtils; public class UserDaoImpl implements UserDao{ @Override /** * 用戶註冊 */ public void save(User user) throws SQLException { QueryRunner qr = new QueryRunner(DataSourceUtils.getDataSource()); /* * `uid` varchar(32) NOT NULL, `username` varchar(20) DEFAULT NULL, `password` varchar(20) DEFAULT NULL, `name` varchar(20) DEFAULT NULL, `email` varchar(30) DEFAULT NULL, `telephone` varchar(20) DEFAULT NULL, `birthday` date DEFAULT NULL, `sex` varchar(10) DEFAULT NULL, `state` int(11) DEFAULT NULL, `code` varchar(64) DEFAULT NULL, */ String sql = "insert into user values(?,?,?,?,?,?,?,?,?,?);"; qr.update(sql, user.getUid(),user.getUsername(),user.getPassword(), user.getName(),user.getEmail(),user.getTelephone(), user.getBirthday(),user.getSex(),user.getState(), user.getCode()); } @Override /** * 經過激活碼獲取用戶 */ public User getByCode(String code) throws Exception { QueryRunner qr = new QueryRunner(DataSourceUtils.getDataSource()); String sql = "select * from user where code = ? limit 1"; return qr.query(sql, new BeanHandler<>(User.class), code); } @Override /** * 更新用戶 */ public void update(User user) throws Exception { QueryRunner qr = new QueryRunner(DataSourceUtils.getDataSource()); /* * `uid` varchar(32) NOT NULL, `username` varchar(20) DEFAULT NULL, `password` varchar(20) DEFAULT NULL, `name` varchar(20) DEFAULT NULL, `email` varchar(30) DEFAULT NULL, `telephone` varchar(20) DEFAULT NULL, `birthday` date DEFAULT NULL, `sex` varchar(10) DEFAULT NULL, `state` int(11) DEFAULT NULL, `code` varchar(64) DEFAULT NULL, */ String sql="update user set password = ?,sex = ?,state = ?,code = ? where uid = ?"; qr.update(sql, user.getPassword(),user.getSex(),user.getState(),user.getCode(),user.getUid()); } @Override /** * 用戶登陸 */ public User getByUsernameAndPwd(String username, String password) throws Exception { QueryRunner qr = new QueryRunner(DataSourceUtils.getDataSource()); String sql = "select * from user where username = ? and password = ? limit 1"; return qr.query(sql, new BeanHandler<>(User.class), username,password); } }
com.itheima.domain
package com.itheima.domain; import java.util.Collection; import java.util.HashMap; import java.util.Map; /** * 購物車 * @author Administrator * */ public class Cart { private Map<String, CartItem> itemMap=new HashMap<String, CartItem>(); private Double total=0.0; /** * 獲取全部的購物項 * @return */ public Collection<CartItem> getCartItems(){ return itemMap.values(); } public Map<String, CartItem> getItemMap() { return itemMap; } public void setItemMap(Map<String, CartItem> itemMap) { this.itemMap = itemMap; } public Double getTotal() { return total; } public void setTotal(Double total) { this.total = total; } /** * 加入到購物車 * @param item */ public void add2cart(CartItem item){ //獲取商品的id String pid = item.getProduct().getPid(); //判斷購物車中是否有 if(itemMap.containsKey(pid)){ //有 修改數量 = 原來數量+新加的數量 //原有的購物項 CartItem oItem = itemMap.get(pid); oItem.setCount(oItem.getCount()+item.getCount()); }else{ //無 itemMap.put(pid, item); } //修改總金額 total += item.getSubtotal(); } /** * 從購物車移除一個購物項 * @param pid */ public void removeFromCart(String pid){ //1.從購物車(map)移除 購物項 CartItem item = itemMap.remove(pid); //2.修改總金額 total -= item.getSubtotal(); } /** * 清空購物車 */ public void clearCart(){ //1.清空map itemMap.clear(); //2.修改總金額 = 0 total=0.0; } }
package com.itheima.domain; /** * 購物項 * @author Administrator * */ public class CartItem { //商品 private Product product; //小計 private Double subtotal; //數量 private Integer count; public Product getProduct() { return product; } public void setProduct(Product product) { this.product = product; } /** * 獲取商品小計 * @return */ public Double getSubtotal() { return product.getShop_price()*count; } /*public void setSubtotal(Double subtotal) { this.subtotal = subtotal; }*/ public Integer getCount() { return count; } public void setCount(Integer count) { this.count = count; } public CartItem(Product product, Integer count) { super(); this.product = product; this.count = count; } }
package com.itheima.domain; public class Category { private String cid; private String cname; public String getCid() { return cid; } public void setCid(String cid) { this.cid = cid; } public String getCname() { return cname; } public void setCname(String cname) { this.cname = cname; } }
package com.itheima.domain; import java.util.ArrayList; import java.util.Date; import java.util.List; /** * 訂單 * @author Administrator * */ public class Order { /** * `oid` varchar(32) NOT NULL, `ordertime` datetime DEFAULT NULL, `total` double DEFAULT NULL, `state` int(11) DEFAULT NULL, `address` varchar(30) DEFAULT NULL, `name` varchar(20) DEFAULT NULL, `telephone` varchar(20) DEFAULT NULL, `uid` varchar(32) DEFAULT NULL, */ private String oid; private Date ordertime; private Double total; private Integer state;//訂單狀態 0:未付款 1:已付款 2:已發貨 3.已完成 private String address; private String name; private String telephone; //表示當前訂單屬於那個用戶 private User user; //表示當前訂單包含的訂單項 private List<OrderItem> items = new ArrayList<>(); public String getOid() { return oid; } public void setOid(String oid) { this.oid = oid; } public Date getOrdertime() { return ordertime; } public void setOrdertime(Date ordertime) { this.ordertime = ordertime; } public Double getTotal() { return total; } public void setTotal(Double total) { this.total = total; } public Integer getState() { return state; } public void setState(Integer state) { this.state = state; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getTelephone() { return telephone; } public void setTelephone(String telephone) { this.telephone = telephone; } public User getUser() { return user; } public void setUser(User user) { this.user = user; } public List<OrderItem> getItems() { return items; } public void setItems(List<OrderItem> items) { this.items = items; } }
package com.itheima.domain; /** * 訂單項 * @author Administrator * */ public class OrderItem { /* * `itemid` varchar(32) NOT NULL, `count` int(11) DEFAULT NULL, `subtotal` double DEFAULT NULL, `pid` varchar(32) DEFAULT NULL, `oid` varchar(32) DEFAULT NULL, */ private String itemid; private Integer count; private Double subtotal; //表示包含那個商品 private Product product; //表示屬於那個訂單 private Order order; public String getItemid() { return itemid; } public void setItemid(String itemid) { this.itemid = itemid; } public Integer getCount() { return count; } public void setCount(Integer count) { this.count = count; } public Double getSubtotal() { return subtotal; } public void setSubtotal(Double subtotal) { this.subtotal = subtotal; } public Product getProduct() { return product; } public void setProduct(Product product) { this.product = product; } public Order getOrder() { return order; } public void setOrder(Order order) { this.order = order; } }
package com.itheima.domain; import java.util.List; public class PageBean<T> { private List<T> data;//當前頁的數據 查詢 limit (pageNumber-1)*pageSize,pageSize private int pageNumber;//當前頁 頁面傳遞過來 private int totalRecord;//總條數 查詢 count(*) private int pageSize;//每頁顯示的數量 固定值 private int totalPage;//總頁數 計算出來 (int)Math.ceil(totalRecord*1.0/pageSize); public List<T> getData() { return data; } public void setData(List<T> data) { this.data = data; } public int getPageNumber() { return pageNumber; } public void setPageNumber(int pageNumber) { this.pageNumber = pageNumber; } public int getTotalRecord() { return totalRecord; } public void setTotalRecord(int totalRecord) { this.totalRecord = totalRecord; } public int getPageSize() { return pageSize; } public void setPageSize(int pageSize) { this.pageSize = pageSize; } /** * 獲取總頁數 * @return */ public int getTotalPage() { return (int)Math.ceil(totalRecord*1.0/pageSize); } /** * 獲取開始索引 * @return */ public int getStartIndex(){ return (pageNumber-1)*pageSize; } public PageBean(int pageNumber, int pageSize) { super(); this.pageNumber = pageNumber; this.pageSize = pageSize; } }
package com.itheima.domain; import java.util.Date; public class Product { /* * `pid` varchar(32) NOT NULL, `pname` varchar(50) DEFAULT NULL, `market_price` double DEFAULT NULL, `shop_price` double DEFAULT NULL, `pimage` varchar(200) DEFAULT NULL, `pdate` date DEFAULT NULL, `is_hot` int(11) DEFAULT NULL, `pdesc` varchar(255) DEFAULT NULL, `pflag` int(11) DEFAULT NULL, `cid` varchar(32) DEFAULT NULL, */ private String pid; private String pname; private Double market_price; private Double shop_price; private String pimage; private Date pdate; private Integer is_hot; //是否熱門 1:熱門 0:不熱門 private String pdesc; private Integer pflag; //是否下架 1:下架 0:未下架 //在多的一方放入一個一的一方的對象 用來表示屬於那個分類 private Category category; public String getPid() { return pid; } public void setPid(String pid) { this.pid = pid; } public String getPname() { return pname; } public void setPname(String pname) { this.pname = pname; } public Double getMarket_price() { return market_price; } public void setMarket_price(Double market_price) { this.market_price = market_price; } public Double getShop_price() { return shop_price; } public void setShop_price(Double shop_price) { this.shop_price = shop_price; } public String getPimage() { return pimage; } public void setPimage(String pimage) { this.pimage = pimage; } public Date getPdate() { return pdate; } public void setPdate(Date pdate) { this.pdate = pdate; } public Integer getIs_hot() { return is_hot; } public void setIs_hot(Integer is_hot) { this.is_hot = is_hot; } public String getPdesc() { return pdesc; } public void setPdesc(String pdesc) { this.pdesc = pdesc; } public Integer getPflag() { return pflag; } public void setPflag(Integer pflag) { this.pflag = pflag; } public Category getCategory() { return category; } public void setCategory(Category category) { this.category = category; } }
package com.itheima.domain; public class User { /* * `uid` varchar(32) NOT NULL, `username` varchar(20) DEFAULT NULL, `password` varchar(20) DEFAULT NULL, `name` varchar(20) DEFAULT NULL, `email` varchar(30) DEFAULT NULL, `telephone` varchar(20) DEFAULT NULL, `birthday` date DEFAULT NULL, `sex` varchar(10) DEFAULT NULL, `state` int(11) DEFAULT NULL, `code` varchar(64) DEFAULT NULL, */ private String uid; private String username; private String password; private String name; private String email; private String telephone; private String birthday; private String sex; private Integer state; private String code; public String getUid() { return uid; } public void setUid(String uid) { this.uid = uid; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getTelephone() { return telephone; } public void setTelephone(String telephone) { this.telephone = telephone; } public String getBirthday() { return birthday; } public void setBirthday(String birthday) { this.birthday = birthday; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public Integer getState() { return state; } public void setState(Integer state) { this.state = state; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } }
com.itheima.service
package com.itheima.service; import java.util.List; import com.itheima.domain.Category; public interface CategoryService { String findAll() throws Exception; String findAllFromRedis() throws Exception; List<Category> findList() throws Exception; void save(Category c) throws Exception; }
package com.itheima.service; import java.util.List; import com.itheima.domain.Order; import com.itheima.domain.PageBean; public interface OrderService { void save(Order order)throws Exception; PageBean<Order> findMyOrdersByPage(int pageNumber, int pageSize, String uid)throws Exception; Order getById(String oid)throws Exception; void update(Order order)throws Exception; List<Order> findAllByState(String state)throws Exception; }
package com.itheima.service; import java.util.List; import com.itheima.domain.PageBean; import com.itheima.domain.Product; public interface ProductService { List<Product> findHot() throws Exception; List<Product> findNew() throws Exception; Product getById(String pid) throws Exception; PageBean<Product> findByPage(int pageNumber, int pageSize, String cid) throws Exception; List<Product> findAll() throws Exception; void save(Product p)throws Exception; }
package com.itheima.service; import com.itheima.domain.User; public interface UserService { void regist(User user) throws Exception; User active(String code) throws Exception; User login(String username, String password) throws Exception; }
com.itheima.service.impl
package com.itheima.service.impl; import java.util.List; import com.itheima.constant.Constant; import com.itheima.dao.CategoryDao; import com.itheima.dao.impl.CategoryDaoImpl; import com.itheima.domain.Category; import com.itheima.service.CategoryService; import com.itheima.utils.BeanFactory; import com.itheima.utils.JedisUtils; import com.itheima.utils.JsonUtil; import redis.clients.jedis.Jedis; public class CategoryServiceImpl implements CategoryService { @Override /** * 後臺展現全部分類 */ public List<Category> findList() throws Exception { CategoryDao cd = (CategoryDao) BeanFactory.getBean("CategoryDao"); return cd.findAll(); } @Override /** * 查詢全部分類 */ public String findAll() throws Exception { /*//1.調用dao 查詢全部分類 CategoryDao cd = new CategoryDaoImpl(); List<Category> list = cd.findAll();*/ List<Category> list=findList(); //2.將list轉換成json字符串 if(list!=null && list.size()>0){ return JsonUtil.list2json(list); } return null; } @Override /** * 從redis中獲取全部的分類 */ public String findAllFromRedis() throws Exception { /* //1.獲取jedis Jedis jedis = JedisUtils.getJedis(); //2.從redis中獲取數據 String value = jedis.get(Constant.STORE_CATEGORY_LIST); //3.判斷數據是否爲空 if(value == null){ //3.1若爲空 ,調用findAll() 將查詢的結果放入redis return value = findAll(); jedis.set(Constant.STORE_CATEGORY_LIST, value); System.out.println("從mysql中獲取"); return value; } //3.2若不爲空,return System.out.println("從redis中獲取"); return value; */ Jedis j =null; String value=null; try { //1.從redis獲取分類信息 try { //1.1獲取鏈接 j = JedisUtils.getJedis(); //1.2 獲取數據 判斷數據是否爲空 value = j.get(Constant.STORE_CATEGORY_LIST); //1.3 若不爲空,直接返回數據 if(value!=null){ System.out.println("緩存中有數據"); return value; } } catch (Exception e) { } //2 redis中 若無數據,則從mysql數據庫中獲取 別忘記將數據並放入redis中 value = findAll(); //3.將value放入redis中 try { j.set(Constant.STORE_CATEGORY_LIST, value); System.out.println("已經將數據放入緩存中"); } catch (Exception e) { } } catch (Exception e) { e.printStackTrace(); throw e; } finally { //釋放jedis JedisUtils.closeJedis(j); } return value; } @Override /** * 添加分類 */ public void save(Category c) throws Exception { //1.調用dao 完成添加 CategoryDao cd = (CategoryDao) BeanFactory.getBean("CategoryDao"); cd.save(c); //2.更新redis Jedis j = null; try { j=JedisUtils.getJedis(); //清除redis中數據 j.del(Constant.STORE_CATEGORY_LIST); } finally { JedisUtils.closeJedis(j); } } }
package com.itheima.service.impl; import java.util.List; import com.itheima.dao.OrderDao; import com.itheima.domain.Order; import com.itheima.domain.OrderItem; import com.itheima.domain.PageBean; import com.itheima.service.OrderService; import com.itheima.utils.BeanFactory; import com.itheima.utils.DataSourceUtils; public class OrderServiceImpl implements OrderService { @Override /** * 保存訂單 */ public void save(Order order) throws Exception{ try { //獲取dao OrderDao od = (OrderDao) BeanFactory.getBean("OrderDao"); //1.開啓事務 DataSourceUtils.startTransaction(); //2.向orders表中插入一條 od.save(order); //3.向orderitem中插入n條 for (OrderItem oi : order.getItems()) { od.saveItem(oi); } //4.事務控制 DataSourceUtils.commitAndClose(); } catch (Exception e) { e.printStackTrace(); DataSourceUtils.rollbackAndClose(); throw e; } } @Override /** * 個人訂單 */ public PageBean<Order> findMyOrdersByPage(int pageNumber, int pageSize, String uid) throws Exception { OrderDao od = (OrderDao) BeanFactory.getBean("OrderDao"); //1.建立pagebean PageBean<Order> pb = new PageBean<>(pageNumber, pageSize); //2.查詢總條數 設置總條數 int totalRecord = od.getTotalRecord(uid); pb.setTotalRecord(totalRecord); //3.查詢當前頁數據 設置當前頁數據 List<Order> data = od.findMyOrdersByPage(pb,uid); pb.setData(data); return pb; } @Override /** * 訂單詳情 */ public Order getById(String oid) throws Exception { OrderDao od = (OrderDao) BeanFactory.getBean("OrderDao"); return od.getById(oid); } @Override /** * 修改訂單 */ public void update(Order order) throws Exception { OrderDao od = (OrderDao) BeanFactory.getBean("OrderDao"); od.update(order); } @Override /** * 後臺查詢訂單列表 */ public List<Order> findAllByState(String state) throws Exception { OrderDao od = (OrderDao) BeanFactory.getBean("OrderDao"); return od.findAllByState(state); } }
package com.itheima.service.impl; import java.util.List; import com.itheima.dao.ProductDao; import com.itheima.dao.impl.ProductDaoImpl; import com.itheima.domain.PageBean; import com.itheima.domain.Product; import com.itheima.service.ProductService; import com.itheima.utils.BeanFactory; public class ProductServiceImpl implements ProductService { @Override /** * 查詢熱門商品 */ public List<Product> findHot() throws Exception { ProductDao pd= (ProductDao) BeanFactory.getBean("ProductDao"); return pd.findHot(); } @Override /** * 查詢最新商品 */ public List<Product> findNew() throws Exception { //ProductDao pd= (ProductDao) BeanFactory.getBean("ProductDao"); ProductDao pd= (ProductDao) BeanFactory.getBean("ProductDao"); return pd.findNew(); } @Override /** * 單個商品詳情 */ public Product getById(String pid) throws Exception { ProductDao pd=(ProductDao) BeanFactory.getBean("ProductDao"); return pd.getById(pid); } @Override /** * 分頁展現分類商品 */ public PageBean<Product> findByPage(int pageNumber, int pageSize, String cid) throws Exception { ProductDao pDao= (ProductDao) BeanFactory.getBean("ProductDao"); //1.建立pagebean PageBean<Product> pb = new PageBean<>(pageNumber, pageSize); //2.設置當前頁數據 List<Product> data = pDao.findByPage(pb,cid); pb.setData(data); //3.設置總記錄數 int totalRecord = pDao.getTotalRecord(cid); pb.setTotalRecord(totalRecord); return pb; } @Override /** * 後臺展現已上架商品 */ public List<Product> findAll() throws Exception { ProductDao pDao= (ProductDao) BeanFactory.getBean("ProductDao"); return pDao.findAll(); } @Override /** * 保存商品 */ public void save(Product p) throws Exception { ProductDao pDao= (ProductDao) BeanFactory.getBean("ProductDao"); pDao.save(p); } }
package com.itheima.service.impl; import com.itheima.constant.Constant; import com.itheima.dao.UserDao; import com.itheima.dao.impl.UserDaoImpl; import com.itheima.domain.User; import com.itheima.service.UserService; import com.itheima.utils.BeanFactory; import com.itheima.utils.MailUtils; public class UserServiceImpl implements UserService { @Override /** * 用戶註冊 */ public void regist(User user) throws Exception { //1.調用dao完成註冊 //UserDao ud=(UserDao) BeanFactory.getBean("UserDao"); UserDao ud=(UserDao) BeanFactory.getBean("UserDao"); ud.save(user); //2.發送激活郵件 String emailMsg="恭喜"+user.getName()+":成爲咱們商城的一員,<a href='http://localhost/store/user?method=active&code="+user.getCode()+"'>點此激活</a>"; MailUtils.sendMail(user.getEmail(), emailMsg); } @Override /** * 用戶激活 */ public User active(String code) throws Exception { UserDao ud=(UserDao) BeanFactory.getBean("UserDao"); //1.經過code獲取用戶 User user=ud.getByCode(code); //1.1 經過激活碼沒有找到 用戶 if(user == null){ return null; } //2.若獲取到了 修改用戶 user.setState(Constant.USER_IS_ACTIVE); user.setCode(null); ud.update(user); return user; } @Override /** * 用戶登陸 */ public User login(String username, String password) throws Exception { UserDao ud=(UserDao) BeanFactory.getBean("UserDao"); return ud.getByUsernameAndPwd(username,password); } }
com.itheima.util
package com.itheima.utils; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import org.dom4j.Document; import org.dom4j.Element; import org.dom4j.io.SAXReader; /** * 獲取javabean的工廠 * @author Administrator * */ public class BeanFactory { public static Object getBean(String id){ try { //1.獲取document對象 Document doc=new SAXReader().read(BeanFactory.class.getClassLoader().getResourceAsStream("beans.xml")); //2.調用api selectSingleNode(表達式) Element beanEle=(Element) doc.selectSingleNode("//bean[@id='"+id+"']"); //3.獲取元素的class屬性 String classValue = beanEle.attributeValue("class"); //4.經過反射返回實現類的對象 final Object newInstance = Class.forName(classValue).newInstance(); //5.判斷是不是dao if(id.endsWith("Dao")){ //如果dao 建立代理對象 Object proxy = Proxy.newProxyInstance(newInstance.getClass().getClassLoader(), newInstance.getClass().getInterfaces(), new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { //判斷是不是save方法,如果save方法 打印一句話 if("save".equals(method.getName())){ System.out.println("執行了dao中的保存操做"); } return method.invoke(newInstance, args); } }); return proxy; } return newInstance; } catch (Exception e) { e.printStackTrace(); System.out.println("獲取bean失敗"); } return null; } public static void main(String[] args) throws Exception { System.out.println(getBean("ProductDao1")); } }
package com.itheima.utils; import javax.servlet.http.Cookie; public class CookUtils { /** * 經過名稱在cookie數組獲取指定的cookie * @param name cookie名稱 * @param cookies cookie數組 * @return */ public static Cookie getCookieByName(String name, Cookie[] cookies) { if(cookies!=null){ for (Cookie c : cookies) { //經過名稱獲取 if(name.equals(c.getName())){ //返回 return c; } } } return null; } }
package com.itheima.utils; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import javax.sql.DataSource; import com.mchange.v2.c3p0.ComboPooledDataSource; public class DataSourceUtils { private static ComboPooledDataSource ds=new ComboPooledDataSource(); private static ThreadLocal<Connection> tl=new ThreadLocal<>(); /** * 獲取數據源 * @return 鏈接池 */ public static DataSource getDataSource(){ return ds; } /** * 從線程中獲取鏈接 * @return 鏈接 * @throws SQLException */ public static Connection getConnection() throws SQLException{ Connection conn = tl.get(); //如果第一次獲取 須要從池中獲取一個鏈接,將這個鏈接和當前線程綁定 if(conn==null){ conn=ds.getConnection(); //將這個鏈接和當前線程綁定 tl.set(conn); } return conn; } /** * 釋放資源 * * @param conn * 鏈接 * @param st * 語句執行者 * @param rs * 結果集 */ public static void closeResource(Connection conn, Statement st, ResultSet rs) { closeResultSet(rs); closeStatement(st); closeConn(conn); } /** * 釋放鏈接 * * @param conn * 鏈接 */ public static void closeConn(Connection conn) { if (conn != null) { try { conn.close(); //和當前線程解綁 tl.remove(); } catch (SQLException e) { e.printStackTrace(); } conn = null; } } /** * 釋放語句執行者 * * @param st * 語句執行者 */ public static void closeStatement(Statement st) { if (st != null) { try { st.close(); } catch (SQLException e) { e.printStackTrace(); } st = null; } } /** * 釋放結果集 * * @param rs * 結果集 */ public static void closeResultSet(ResultSet rs) { if (rs != null) { try { rs.close(); } catch (SQLException e) { e.printStackTrace(); } rs = null; } } /** * 開始事務 * @throws SQLException */ public static void startTransaction() throws SQLException{ //1.獲取鏈接 Connection conn=getConnection(); //2.開始 conn.setAutoCommit(false); } /** * 事務提交 */ public static void commitAndClose(){ try { //0.獲取鏈接 Connection conn = getConnection(); //1.提交事務 conn.commit(); //2.關閉且移除 closeConn(conn); } catch (SQLException e) { } } /** * 提交回顧 */ public static void rollbackAndClose(){ try { //0.獲取鏈接 Connection conn = getConnection(); //1.事務回顧 conn.rollback(); //2.關閉且移除 closeConn(conn); } catch (SQLException e) { } } }
package com.itheima.utils; import com.itheima.constant.Constant; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPoolConfig; public class JedisUtils { //建立鏈接池 private static final JedisPoolConfig config; private static final JedisPool pool; static{ config=new JedisPoolConfig(); config.setMaxTotal(30); config.setMaxIdle(2); pool=new JedisPool(config, Constant.REDIS_HOST, Constant.REDIS_PORT); } //獲取鏈接的方法 public static Jedis getJedis(){ return pool.getResource(); } //釋放鏈接 public static void closeJedis(Jedis j){ if(j!=null){ j.close(); } } }
package com.itheima.utils; import java.util.List; import java.util.Map; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import net.sf.json.JsonConfig; import net.sf.json.util.CycleDetectionStrategy; import net.sf.json.xml.XMLSerializer; /** * 處理json數據格式的工具類 * * @Date 2013-3-31 * @version 1.0 */ public class JsonUtil { /** * 將數組轉換成String類型的JSON數據格式 * * @param objects * @return */ public static String array2json(Object[] objects){ JSONArray jsonArray = JSONArray.fromObject(objects); return jsonArray.toString(); } /** * 將list集合轉換成String類型的JSON數據格式 * * @param list * @return */ public static String list2json(List list){ JSONArray jsonArray = JSONArray.fromObject(list); return jsonArray.toString(); } /** * 將map集合轉換成String類型的JSON數據格式 * * @param map * @return */ public static String map2json(Map map){ JSONObject jsonObject = JSONObject.fromObject(map); return jsonObject.toString(); } /** * 將Object對象轉換成String類型的JSON數據格式 * * @param object * @return */ public static String object2json(Object object){ JSONObject jsonObject = JSONObject.fromObject(object); return jsonObject.toString(); } /** * 將XML數據格式轉換成String類型的JSON數據格式 * * @param xml * @return */ public static String xml2json(String xml){ JSONArray jsonArray = (JSONArray) new XMLSerializer().read(xml); return jsonArray.toString(); } /** * 除去不想生成的字段(特別適合去掉級聯的對象) * * @param excludes * @return */ public static JsonConfig configJson(String[] excludes) { JsonConfig jsonConfig = new JsonConfig(); jsonConfig.setExcludes(excludes); jsonConfig.setIgnoreDefaultExcludes(true); jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT); return jsonConfig; } }
package com.itheima.utils; import java.util.Properties; import javax.mail.Authenticator; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage.RecipientType; public class MailUtils { public static void sendMail(String email, String emailMsg) throws AddressException, MessagingException { // 1.建立一個程序與郵件服務器會話對象 Session Properties props = new Properties(); //設置發送的協議 props.setProperty("mail.transport.protocol", "SMTP"); //設置發送郵件的服務器 props.setProperty("mail.host", "localhost"); props.setProperty("mail.smtp.auth", "true");// 指定驗證爲true // 建立驗證器 Authenticator auth = new Authenticator() { public PasswordAuthentication getPasswordAuthentication() { //設置發送人的賬號和密碼 return new PasswordAuthentication("service", "123"); } }; Session session = Session.getInstance(props, auth); // 2.建立一個Message,它至關因而郵件內容 Message message = new MimeMessage(session); //設置發送者 message.setFrom(new InternetAddress("service@store.com")); //設置發送方式與接收者 message.setRecipient(RecipientType.TO, new InternetAddress(email)); //設置郵件主題 message.setSubject("用戶激活"); //設置郵件內容 message.setContent(emailMsg, "text/html;charset=utf-8"); // 3.建立 Transport用於將郵件發送 Transport.send(message); } }
package com.itheima.utils; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; public class PaymentUtil { private static String encodingCharset = "UTF-8"; /** * 生成hmac方法 * * @param p0_Cmd 業務類型 * @param p1_MerId 商戶編號 * @param p2_Order 商戶訂單號 * @param p3_Amt 支付金額 * @param p4_Cur 交易幣種 * @param p5_Pid 商品名稱 * @param p6_Pcat 商品種類 * @param p7_Pdesc 商品描述 * @param p8_Url 商戶接收支付成功數據的地址 * @param p9_SAF 送貨地址 * @param pa_MP 商戶擴展信息 * @param pd_FrpId 銀行編碼 * @param pr_NeedResponse 應答機制 * @param keyValue 商戶密鑰 * @return */ public static String buildHmac(String p0_Cmd,String p1_MerId, String p2_Order, String p3_Amt, String p4_Cur,String p5_Pid, String p6_Pcat, String p7_Pdesc,String p8_Url, String p9_SAF,String pa_MP,String pd_FrpId, String pr_NeedResponse,String keyValue) { StringBuilder sValue = new StringBuilder(); // 業務類型 sValue.append(p0_Cmd); // 商戶編號 sValue.append(p1_MerId); // 商戶訂單號 sValue.append(p2_Order); // 支付金額 sValue.append(p3_Amt); // 交易幣種 sValue.append(p4_Cur); // 商品名稱 sValue.append(p5_Pid); // 商品種類 sValue.append(p6_Pcat); // 商品描述 sValue.append(p7_Pdesc); // 商戶接收支付成功數據的地址 sValue.append(p8_Url); // 送貨地址 sValue.append(p9_SAF); // 商戶擴展信息 sValue.append(pa_MP); // 銀行編碼 sValue.append(pd_FrpId); // 應答機制 sValue.append(pr_NeedResponse); return PaymentUtil.hmacSign(sValue.toString(), keyValue); } /** * 返回校驗hmac方法 * * @param hmac 支付網關發來的加密驗證碼 * @param p1_MerId 商戶編號 * @param r0_Cmd 業務類型 * @param r1_Code 支付結果 * @param r2_TrxId 易寶支付交易流水號 * @param r3_Amt 支付金額 * @param r4_Cur 交易幣種 * @param r5_Pid 商品名稱 * @param r6_Order 商戶訂單號 * @param r7_Uid 易寶支付會員ID * @param r8_MP 商戶擴展信息 * @param r9_BType 交易結果返回類型 * @param keyValue 密鑰 * @return */ public static boolean verifyCallback(String hmac, String p1_MerId, String r0_Cmd, String r1_Code, String r2_TrxId, String r3_Amt, String r4_Cur, String r5_Pid, String r6_Order, String r7_Uid, String r8_MP, String r9_BType, String keyValue) { StringBuilder sValue = new StringBuilder(); // 商戶編號 sValue.append(p1_MerId); // 業務類型 sValue.append(r0_Cmd); // 支付結果 sValue.append(r1_Code); // 易寶支付交易流水號 sValue.append(r2_TrxId); // 支付金額 sValue.append(r3_Amt); // 交易幣種 sValue.append(r4_Cur); // 商品名稱 sValue.append(r5_Pid); // 商戶訂單號 sValue.append(r6_Order); // 易寶支付會員ID sValue.append(r7_Uid); // 商戶擴展信息 sValue.append(r8_MP); // 交易結果返回類型 sValue.append(r9_BType); String sNewString = PaymentUtil.hmacSign(sValue.toString(), keyValue); return sNewString.equals(hmac); } /** * @param aValue * @param aKey * @return */ public static String hmacSign(String aValue, String aKey) { byte k_ipad[] = new byte[64]; byte k_opad[] = new byte[64]; byte keyb[]; byte value[]; try { keyb = aKey.getBytes(encodingCharset); value = aValue.getBytes(encodingCharset); } catch (UnsupportedEncodingException e) { keyb = aKey.getBytes(); value = aValue.getBytes(); } Arrays.fill(k_ipad, keyb.length, 64, (byte) 54); Arrays.fill(k_opad, keyb.length, 64, (byte) 92); for (int i = 0; i < keyb.length; i++) { k_ipad[i] = (byte) (keyb[i] ^ 0x36); k_opad[i] = (byte) (keyb[i] ^ 0x5c); } MessageDigest md = null; try { md = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { return null; } md.update(k_ipad); md.update(value); byte dg[] = md.digest(); md.reset(); md.update(k_opad); md.update(dg, 0, 16); dg = md.digest(); return toHex(dg); } public static String toHex(byte input[]) { if (input == null) return null; StringBuffer output = new StringBuffer(input.length * 2); for (int i = 0; i < input.length; i++) { int current = input[i] & 0xff; if (current < 16) output.append("0"); output.append(Integer.toString(current, 16)); } return output.toString(); } /** * * @param args * @param key * @return */ public static String getHmac(String[] args, String key) { if (args == null || args.length == 0) { return (null); } StringBuffer str = new StringBuffer(); for (int i = 0; i < args.length; i++) { str.append(args[i]); } return (hmacSign(str.toString(), key)); } /** * @param aValue * @return */ public static String digest(String aValue) { aValue = aValue.trim(); byte value[]; try { value = aValue.getBytes(encodingCharset); } catch (UnsupportedEncodingException e) { value = aValue.getBytes(); } MessageDigest md = null; try { md = MessageDigest.getInstance("SHA"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); return null; } return toHex(md.digest(value)); } // public static void main(String[] args) { // System.out.println(hmacSign("AnnulCard1000043252120080620160450.0http://localhost/SZXpro/callback.asp榪?4564868265473632445648682654736324511","8UPp0KE8sq73zVP370vko7C39403rtK1YwX40Td6irH216036H27Eb12792t")); // } }
package com.itheima.utils; import java.util.Random; import java.util.UUID; public class UploadUtils { /** * 獲取文件真實名稱 * 因爲瀏覽器的不一樣獲取的名稱可能爲:c:/upload/1.jpg或者1.jpg * 最終獲取的爲 1.jpg * @param name 上傳上來的文件名稱 * @return 真實名稱 */ public static String getRealName(String name){ //獲取最後一個"/" int index = name.lastIndexOf("\\"); return name.substring(index+1); } /** * 獲取隨機名稱 * @param realName 真實名稱 * @return uuid 隨機名稱 */ public static String getUUIDName(String realName){ //realname 多是 1.jpg 也多是 1 //獲取後綴名 int index = realName.lastIndexOf("."); if(index==-1){ return UUID.randomUUID().toString().replace("-", "").toUpperCase(); }else{ return UUID.randomUUID().toString().replace("-", "").toUpperCase()+realName.substring(index); } } /** * 獲取文件目錄,能夠獲取256個隨機目錄 * @return 隨機目錄 */ public static String getDir(){ String s="0123456789ABCDEF"; Random r = new Random(); return "/"+s.charAt(r.nextInt(16))+"/"+s.charAt(r.nextInt(16)); } public static void main(String[] args) { //String s="G:\\day17-基礎增強\\resource\\1.jpg"; String s="1"; String realName = getRealName(s); System.out.println(realName); String uuidName = getUUIDName(realName); System.out.println(uuidName); String dir = getDir(); System.out.println(dir); } }
package com.itheima.utils; import java.util.UUID; public class UUIDUtils { /** * 隨機生成id * @return */ public static String getId(){ return UUID.randomUUID().toString().replace("-", "").toUpperCase(); } /** * 生成隨機碼 * @return */ public static String getCode(){ return getId(); } public static void main(String[] args) { System.out.println(getId()); System.out.println(getCode()); } }
com.itheima.web.filter
package com.itheima.web.filter; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.Map; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletResponse; /** * 統一編碼 * @author Administrator * */ public class EncodingFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { // TODO Auto-generated method stub } @Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { //1.強轉 HttpServletRequest request=(HttpServletRequest) req; HttpServletResponse response=(HttpServletResponse) resp; //2.放行 chain.doFilter(new MyRequest(request), response); } @Override public void destroy() { // TODO Auto-generated method stub } } class MyRequest extends HttpServletRequestWrapper{ private HttpServletRequest request; private boolean flag=true; public MyRequest(HttpServletRequest request) { super(request); this.request=request; } @Override public String getParameter(String name) { if(name==null || name.trim().length()==0){ return null; } String[] values = getParameterValues(name); if(values==null || values.length==0){ return null; } return values[0]; } @Override /** * hobby=[eat,drink] */ public String[] getParameterValues(String name) { if(name==null || name.trim().length()==0){ return null; } Map<String, String[]> map = getParameterMap(); if(map==null || map.size()==0){ return null; } return map.get(name); } @Override /** * map{ username=[tom],password=[123],hobby=[eat,drink]} */ public Map<String,String[]> getParameterMap() { /** * 首先判斷請求方式 * 若爲post request.setchar...(utf-8) * 若爲get 將map中的值遍歷編碼就能夠了 */ String method = request.getMethod(); if("post".equalsIgnoreCase(method)){ try { request.setCharacterEncoding("utf-8"); return request.getParameterMap(); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } }else if("get".equalsIgnoreCase(method)){ Map<String,String[]> map = request.getParameterMap(); if(flag){ for (String key:map.keySet()) { String[] arr = map.get(key); //繼續遍歷數組 for(int i=0;i<arr.length;i++){ //編碼 try { arr[i]=new String(arr[i].getBytes("iso8859-1"),"utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } } flag=false; } //須要遍歷map 修改value的每個數據的編碼 return map; } return super.getParameterMap(); } }
package com.itheima.web.filter; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.itheima.domain.User; public class PrivilegeFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { // TODO Auto-generated method stub } @Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { //1.強轉 HttpServletRequest request =(HttpServletRequest) req; HttpServletResponse response =(HttpServletResponse) resp; //2.邏輯 //從session中獲取用戶 User user = (User) request.getSession().getAttribute("user"); if(user == null){ //未登陸 request.setAttribute("msg", "請先登陸"); request.getRequestDispatcher("/jsp/msg.jsp").forward(request, response); return; } //3.放行 chain.doFilter(request, response); } @Override public void destroy() { // TODO Auto-generated method stub } }
com.itheima.web.servlet
package com.itheima.web.servlet; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.commons.io.IOUtils; import com.itheima.constant.Constant; import com.itheima.domain.Category; import com.itheima.domain.Product; import com.itheima.service.ProductService; import com.itheima.utils.BeanFactory; import com.itheima.utils.UUIDUtils; import com.itheima.utils.UploadUtils; /** * 保存商品 */ public class AddProductServlet extends HttpServlet { private static final long serialVersionUID = 1L; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //0.使用fileuload保存圖片和將商品的信息放入map中 //0.1 建立map 存放商品的信息 Map<String,Object> map=new HashMap<>(); //0.2 建立磁盤文件項工廠 (設置臨時文件的大小和位置) DiskFileItemFactory factory = new DiskFileItemFactory(); //0.3 建立核心上傳對象 ServletFileUpload upload = new ServletFileUpload(factory); //0.4 解析request List<FileItem> list = upload.parseRequest(request); //0.5遍歷list 獲取每個文件項 for (FileItem fi : list) { //0.6獲取name屬性值 String key = fi.getFieldName(); //0.7判斷是不是普通的上傳組件 if(fi.isFormField()){ //普通 map.put(key, fi.getString("utf-8")); }else{ //文件 //a.獲取文件的名稱 1.jpg String name = fi.getName(); //b.獲取文件真實名稱 1.jpg String realName = UploadUtils.getRealName(name); //c.獲取文件的隨機名稱 12312312434234.jpg String uuidName = UploadUtils.getUUIDName(realName); //d.獲取隨機目錄 /a/3 String dir = UploadUtils.getDir(); //e.獲取文件內容(輸入流) InputStream is = fi.getInputStream(); //f.建立輸出流 //獲取products目錄的真實路徑 String productPath = getServletContext().getRealPath("/products"); //建立隨機目錄 File dirFile = new File(productPath,dir); if(!dirFile.exists()){ dirFile.mkdirs(); } // d:/tomcat/webapps/store/prouduct/a/3/12312312434234.jpg FileOutputStream os = new FileOutputStream(new File(dirFile,uuidName)); //g.對拷流 IOUtils.copy(is, os); //h.釋放資源 os.close(); is.close(); //i.刪除臨時文件 fi.delete(); //j.將商品的路徑放入map中 prouduct/a/3/12312312434234.jpg map.put(key, "products"+dir+"/"+uuidName); } } //1.封裝product對象 Product p = new Product(); //1.1.手動設置 pid map.put("pid", UUIDUtils.getId()); //1.2.手動設置 pdate map.put("pdate", new Date()); //1.3.手動設置 pflag 上架 map.put("pflag", Constant.PRODUCT_IS_UP); //1.4.使用beanutils封裝 BeanUtils.populate(p, map); //1.5.手動設置 category Category c = new Category(); c.setCid((String)map.get("cid")); p.setCategory(c); //2.調用service 完成保存 ProductService ps = (ProductService) BeanFactory.getBean("ProductService"); ps.save(p); //3.重定向 response.sendRedirect(request.getContextPath()+"/adminProduct?method=findAll"); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("保存商品失敗"); } } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } }
package com.itheima.web.servlet; import java.io.IOException; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.itheima.domain.Category; import com.itheima.service.CategoryService; import com.itheima.utils.BeanFactory; import com.itheima.utils.UUIDUtils; import com.itheima.web.servlet.base.BaseServlet; /** * 後臺分類管理模塊 */ public class AdminCategoryServlet extends BaseServlet { private static final long serialVersionUID = 1L; /** * 添加分類 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String save(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //1.封裝category對象 Category c = new Category(); c.setCid(UUIDUtils.getId()); c.setCname(request.getParameter("cname")); //2.調用service完成添加操做 CategoryService cs = (CategoryService) BeanFactory.getBean("CategoryService"); cs.save(c); //3.重定向 response.sendRedirect(request.getContextPath()+"/adminCategory?method=findAll"); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(); } return null; } /** * 跳轉到添加頁面 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String addUI(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { return "/admin/category/add.jsp"; } /** * 展現全部分類 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String findAll(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //1.調用service 獲取全部的分類 CategoryService cs = (CategoryService) BeanFactory.getBean("CategoryService"); List<Category> list=cs.findList(); //2.將返回值放入request域中 請求轉發 request.setAttribute("list", list); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(); } return "/admin/category/list.jsp"; } }
package com.itheima.web.servlet; import java.io.IOException; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.itheima.constant.Constant; import com.itheima.domain.Order; import com.itheima.domain.OrderItem; import com.itheima.service.OrderService; import com.itheima.utils.BeanFactory; import com.itheima.utils.JsonUtil; import com.itheima.web.servlet.base.BaseServlet; import net.sf.json.JSONArray; import net.sf.json.JsonConfig; /** * 後臺訂單模塊 */ public class AdminOrderServlet extends BaseServlet { private static final long serialVersionUID = 1L; /** * 修改訂單狀態 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String updateState(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //1.獲取oid String oid = request.getParameter("oid"); //2.調用service 獲取訂單 OrderService os = (OrderService) BeanFactory.getBean("OrderService"); Order order = os.getById(oid); //3.設置訂單的狀態,更新 order.setState(Constant.ORDER_YIFAHUO); os.update(order); //4.重定向 response.sendRedirect(request.getContextPath()+"/adminOrder?method=findAllByState&state=1"); } catch (Exception e) { } return null; } /** * 展現訂單詳情 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String showDetail(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //0.設置編碼 response.setContentType("text/html;charset=utf-8"); //1.獲取oid String oid = request.getParameter("oid"); //2.調用service 獲取訂單 OrderService os = (OrderService) BeanFactory.getBean("OrderService"); Order order = os.getById(oid); //3.獲取訂單的訂單項列表 轉成json 寫回瀏覽器 if(order != null){ List<OrderItem> list = order.getItems(); if(list != null && list.size()>0){ //response.getWriter().println(JsonUtil.list2json(list)); JsonConfig config = JsonUtil.configJson(new String[]{"order","pdate","pdesc","itemid"}); response.getWriter().println(JSONArray.fromObject(list, config)); } } } catch (Exception e) { e.printStackTrace(); } return null; } /** * 後臺按照狀態查詢訂單列表 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String findAllByState(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //1.獲取state String state = request.getParameter("state"); //2.調用service 獲取不一樣的列表 OrderService os = (OrderService) BeanFactory.getBean("OrderService"); List<Order> list=os.findAllByState(state); //3.將list放入request域中,請求轉發 request.setAttribute("list", list); } catch (Exception e) { } return "/admin/order/list.jsp"; } }
package com.itheima.web.servlet; import java.io.IOException; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.itheima.domain.Product; import com.itheima.service.CategoryService; import com.itheima.service.ProductService; import com.itheima.utils.BeanFactory; import com.itheima.web.servlet.base.BaseServlet; /** * 後臺商品模塊 */ public class AdminProductServlet extends BaseServlet { private static final long serialVersionUID = 1L; /** * 跳轉到添加的頁面上 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String addUI(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //調用categoryservice 查詢全部分類 CategoryService cs = (CategoryService) BeanFactory.getBean("CategoryService"); request.setAttribute("list", cs.findList()); } catch (Exception e) { } return "/admin/product/add.jsp"; } /** * 展現已上架商品列表 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String findAll(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //1.調用service 查詢以上架商品 ProductService ps = (ProductService) BeanFactory.getBean("ProductService"); List<Product> list = ps.findAll(); //2.將返回值放入request中,請求轉發 request.setAttribute("list", list); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(); } return "/admin/product/list.jsp"; } }
package com.itheima.web.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.itheima.domain.Cart; import com.itheima.domain.CartItem; import com.itheima.domain.Product; import com.itheima.service.ProductService; import com.itheima.utils.BeanFactory; import com.itheima.web.servlet.base.BaseServlet; /** * 購物車模塊 */ public class CartServlet extends BaseServlet { private static final long serialVersionUID = 1L; public String clear(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //1.獲取購物車 執行清空操做 getCart(request).clearCart(); //2.重定向 response.sendRedirect(request.getContextPath()+"/jsp/cart.jsp"); return null; } /** * 從購物車移除商品 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String remove(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //1.獲取商品的pid String pid = request.getParameter("pid"); //2.獲取購物車 執行移除 getCart(request).removeFromCart(pid); //3.重定向 response.sendRedirect(request.getContextPath()+"/jsp/cart.jsp"); return null; } /** * 加入購物車 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String add2cart(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //1.獲取pid count String pid = request.getParameter("pid"); int count = Integer.parseInt(request.getParameter("count")); //2.封裝cartitem //調用service獲取product ProductService ps = (ProductService) BeanFactory.getBean("ProductService"); Product product = ps.getById(pid); //建立cartitem CartItem cartItem = new CartItem(product, count); //3.將cartitem加入購物車 //獲取購物車 Cart cart=getCart(request); cart.add2cart(cartItem); //4.重定向 response.sendRedirect(request.getContextPath()+"/jsp/cart.jsp"); } catch (Exception e) { e.printStackTrace(); request.setAttribute("msg", "加入購物車失敗"); return "/jsp/msg.jsp"; } return null; } /** * 獲取購物車 * @param request * @return */ private Cart getCart(HttpServletRequest request) { Cart cart = (Cart) request.getSession().getAttribute("cart"); if(cart == null){ cart = new Cart(); //將cart放入session中 request.getSession().setAttribute("cart", cart); } return cart; } }
package com.itheima.web.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.itheima.service.CategoryService; import com.itheima.service.impl.CategoryServiceImpl; import com.itheima.web.servlet.base.BaseServlet; /** * 前臺分類模塊 */ public class CategoryServlet extends BaseServlet { private static final long serialVersionUID = 1L; /** * 查詢全部分類 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String findAll(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //0.設置響應編碼 response.setContentType("text/html;charset=utf-8"); //1.調用service,查詢全部分類,返回值 json字符串 CategoryService cs = new CategoryServiceImpl(); //從mysql獲取列表 //String value = cs.findAll(); //從redis中獲取列表 String value = cs.findAllFromRedis(); //2.將字符串寫回瀏覽器 response.getWriter().println(value); } catch (Exception e) { } return null; } }
package com.itheima.web.servlet; import java.io.IOException; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.itheima.domain.Product; import com.itheima.service.ProductService; import com.itheima.service.impl.ProductServiceImpl; import com.itheima.web.servlet.base.BaseServlet; /** 首頁模塊 */ public class IndexServlet extends BaseServlet { private static final long serialVersionUID = 1L; @Override public String index(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //1.調用productservice查詢最新商品 和 熱門商品 ProductService ps = new ProductServiceImpl(); List<Product> hotList=ps.findHot(); List<Product> newList=ps.findNew(); //2.將兩個list都放入request域中 request.setAttribute("hList", hotList); request.setAttribute("nList", newList); } catch (Exception e) { } return "/jsp/index.jsp"; } }
package com.itheima.web.servlet; import java.io.IOException; import java.util.Date; import java.util.ResourceBundle; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.itheima.constant.Constant; import com.itheima.domain.Cart; import com.itheima.domain.CartItem; import com.itheima.domain.Order; import com.itheima.domain.OrderItem; import com.itheima.domain.PageBean; import com.itheima.domain.User; import com.itheima.service.OrderService; import com.itheima.utils.BeanFactory; import com.itheima.utils.PaymentUtil; import com.itheima.utils.UUIDUtils; import com.itheima.web.servlet.base.BaseServlet; /** * 訂單模塊 */ public class OrderServlet extends BaseServlet { private static final long serialVersionUID = 1L; /** * 獲取訂單詳情 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String getById(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //1.獲取oid String oid = request.getParameter("oid"); //2.調用service 查詢單個訂單 OrderService os = (OrderService) BeanFactory.getBean("OrderService"); Order order = os.getById(oid); //3.請求轉發 request.setAttribute("bean",order); } catch (Exception e) { e.printStackTrace(); request.setAttribute("msg", "查詢訂單詳情失敗"); return "/jsp/msg.jsp"; } return "/jsp/order_info.jsp"; } /** * 個人訂單 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String findMyOrdersByPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //1.獲取pageNumber 設置pagesize 獲取userid int pageNumber = Integer.parseInt(request.getParameter("pageNumber")); int pageSize=3; User user=(User)request.getSession().getAttribute("user"); if(user == null){ //未登陸 提示 request.setAttribute("msg", "請先登陸"); return "/jsp/msg.jsp"; } //2.調用service獲取當前頁全部數據 pagebean OrderService os = (OrderService) BeanFactory.getBean("OrderService"); PageBean<Order> bean = os.findMyOrdersByPage(pageNumber,pageSize,user.getUid()); //3.將pagebean放入request域中,請求轉發 order_list.jsp request.setAttribute("pb", bean); } catch (Exception e) { e.printStackTrace(); request.setAttribute("msg", "獲取個人訂單失敗"); return "/jsp/msg.jsp"; } return "/jsp/order_list.jsp"; } /** * 保存訂單 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String save(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //-1.從session中獲取user User user=(User) request.getSession().getAttribute("user"); if(user == null){ //未登陸 提示 request.setAttribute("msg", "請先登陸!"); return "/jsp/msg.jsp"; } //0.獲取購物車 Cart cart=(Cart) request.getSession().getAttribute("cart"); //1.封裝訂單對象 //1.1建立對象 Order order = new Order(); //1.2設置oid order.setOid(UUIDUtils.getId()); //1.3設置ordertime order.setOrdertime(new Date()); //1.4設置total 購物車中 order.setTotal(cart.getTotal()); //1.5設置state order.setState(Constant.ORDER_WEIFUKUAN); //1.6設置user order.setUser(user); //1.7設置items(訂單項列表) 遍歷購物項列表 for (CartItem ci : cart.getCartItems()) { //1.7.1封裝成orderitem //a.建立orderitem OrderItem oi = new OrderItem(); //b.設置itemid uuid oi.setItemid(UUIDUtils.getId()); //c.設置count 從ci中獲取 oi.setCount(ci.getCount()); //d.設置subtotal 從ci中獲取 oi.setSubtotal(ci.getSubtotal()); //e.設置product 從ci中獲取 oi.setProduct(ci.getProduct()); //f.設置order oi.setOrder(order); //1.7.2 將orderitem加入order 的items中 order.getItems().add(oi); } //2.調用orderservice完成保存操做 OrderService os = (OrderService) BeanFactory.getBean("OrderService"); os.save(order); //2.9 清空購物車 //request.getSession().getAttribute("cart") cart.clearCart(); //3.請求轉發到 order_info.jsp request.setAttribute("bean", order); } catch (Exception e) { } return "/jsp/order_info.jsp"; } /** * 在線支付 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String pay(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //1.獲取收穫信息 獲取oid 獲取銀行 //2.調用service獲取訂單 修改收穫人信息 更新訂單 //3.拼接給第三方的url //4.重定向 try { //接受參數 String address=request.getParameter("address"); String name=request.getParameter("name"); String telephone=request.getParameter("telephone"); String oid=request.getParameter("oid"); //經過id獲取order OrderService s=(OrderService) BeanFactory.getBean("OrderService"); Order order = s.getById(oid); order.setAddress(address); order.setName(name); order.setTelephone(telephone); //更新order s.update(order); // 組織發送支付公司須要哪些數據 String pd_FrpId = request.getParameter("pd_FrpId"); String p0_Cmd = "Buy"; String p1_MerId = ResourceBundle.getBundle("merchantInfo").getString("p1_MerId"); String p2_Order = oid; String p3_Amt = "0.01"; String p4_Cur = "CNY"; String p5_Pid = ""; String p6_Pcat = ""; String p7_Pdesc = ""; // 支付成功回調地址 ---- 第三方支付公司會訪問、用戶訪問 // 第三方支付能夠訪問網址 String p8_Url = ResourceBundle.getBundle("merchantInfo").getString("responseURL"); String p9_SAF = ""; String pa_MP = ""; String pr_NeedResponse = "1"; // 加密hmac 須要密鑰 String keyValue = ResourceBundle.getBundle("merchantInfo").getString("keyValue"); String hmac = PaymentUtil.buildHmac(p0_Cmd, p1_MerId, p2_Order, p3_Amt, p4_Cur, p5_Pid, p6_Pcat, p7_Pdesc, p8_Url, p9_SAF, pa_MP, pd_FrpId, pr_NeedResponse, keyValue); //發送給第三方 StringBuffer sb = new StringBuffer("https://www.yeepay.com/app-merchant-proxy/node?"); sb.append("p0_Cmd=").append(p0_Cmd).append("&"); sb.append("p1_MerId=").append(p1_MerId).append("&"); sb.append("p2_Order=").append(p2_Order).append("&"); sb.append("p3_Amt=").append(p3_Amt).append("&"); sb.append("p4_Cur=").append(p4_Cur).append("&"); sb.append("p5_Pid=").append(p5_Pid).append("&"); sb.append("p6_Pcat=").append(p6_Pcat).append("&"); sb.append("p7_Pdesc=").append(p7_Pdesc).append("&"); sb.append("p8_Url=").append(p8_Url).append("&"); sb.append("p9_SAF=").append(p9_SAF).append("&"); sb.append("pa_MP=").append(pa_MP).append("&"); sb.append("pd_FrpId=").append(pd_FrpId).append("&"); sb.append("pr_NeedResponse=").append(pr_NeedResponse).append("&"); sb.append("hmac=").append(hmac); response.sendRedirect(sb.toString()); } catch (Exception e) { e.printStackTrace(); request.setAttribute("msg", "支付失敗"); return "/jsp/msg.jsp"; } return null; } /** * 支付成功以後的回調 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String callback(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //1.獲取第三方發送過來的數據 //2.獲取訂單 修改訂單狀態 //3.更新訂單 try { String p1_MerId = request.getParameter("p1_MerId"); String r0_Cmd = request.getParameter("r0_Cmd"); String r1_Code = request.getParameter("r1_Code"); String r2_TrxId = request.getParameter("r2_TrxId"); String r3_Amt = request.getParameter("r3_Amt"); String r4_Cur = request.getParameter("r4_Cur"); String r5_Pid = request.getParameter("r5_Pid"); String r6_Order = request.getParameter("r6_Order"); String r7_Uid = request.getParameter("r7_Uid"); String r8_MP = request.getParameter("r8_MP"); String r9_BType = request.getParameter("r9_BType"); String rb_BankId = request.getParameter("rb_BankId"); String ro_BankOrderId = request.getParameter("ro_BankOrderId"); String rp_PayDate = request.getParameter("rp_PayDate"); String rq_CardNo = request.getParameter("rq_CardNo"); String ru_Trxtime = request.getParameter("ru_Trxtime"); // 身份校驗 --- 判斷是否是支付公司通知你 String hmac = request.getParameter("hmac"); String keyValue = ResourceBundle.getBundle("merchantInfo").getString( "keyValue"); // 本身對上面數據進行加密 --- 比較支付公司發過來hamc boolean isValid = PaymentUtil.verifyCallback(hmac, p1_MerId, r0_Cmd, r1_Code, r2_TrxId, r3_Amt, r4_Cur, r5_Pid, r6_Order, r7_Uid, r8_MP, r9_BType, keyValue); if (isValid) { // 響應數據有效 if (r9_BType.equals("1")) { // 瀏覽器重定向 System.out.println("111"); request.setAttribute("msg", "您的訂單號爲:"+r6_Order+",金額爲:"+r3_Amt+"已經支付成功,等待發貨~~"); } else if (r9_BType.equals("2")) { // 服務器點對點 --- 支付公司通知你 System.out.println("付款成功!222"); // 修改訂單狀態 爲已付款 // 回覆支付公司 response.getWriter().print("success"); } //修改訂單狀態 OrderService s=(OrderService) BeanFactory.getBean("OrderService"); Order order = s.getById(r6_Order); order.setState(Constant.ORDER_YIFUKUAN); s.update(order); } else { // 數據無效 System.out.println("數據被篡改!"); } } catch (Exception e) { e.printStackTrace(); request.setAttribute("msg", "支付失敗"); } return "/jsp/msg.jsp"; } }
package com.itheima.web.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.itheima.domain.PageBean; import com.itheima.domain.Product; import com.itheima.service.ProductService; import com.itheima.service.impl.ProductServiceImpl; import com.itheima.web.servlet.base.BaseServlet; /** * 前臺商品模塊 */ public class ProductServlet extends BaseServlet { private static final long serialVersionUID = 1L; /** * 分類商品分頁展現 */ public String findByPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //1.獲取pagenumber cid 設置pagesize /*String parameter = request.getParameter("pageNumber");*/ int pageNumber = 1; try { pageNumber = Integer.parseInt(request.getParameter("pageNumber")); } catch (NumberFormatException e) { } int pageSize = 12; String cid = request.getParameter("cid"); //2.調用service 分頁查詢商品 參數:3個, 返回值:pagebean ProductService ps = new ProductServiceImpl(); PageBean<Product> bean=ps.findByPage(pageNumber,pageSize,cid); //3.將pagebean放入request中,請求轉發 product_list.jsp request.setAttribute("pb", bean); } catch (Exception e) { request.setAttribute("msg", "分頁查詢失敗"); return "/jsp/msg.jsp"; } return "/jsp/product_list.jsp"; } /** * 商品詳情 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String getById(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //1.獲取pid String pid = request.getParameter("pid"); //2.調用service獲取單個商品 參數:pid 返回值:product ProductService ps =new ProductServiceImpl(); Product pro=ps.getById(pid); //3.將product放入request域中,請求轉發 /jsp/product_info.jsp request.setAttribute("bean", pro); } catch (Exception e) { request.setAttribute("msg", "查詢單個商品失敗"); return "/jsp/msg.jsp"; } return "/jsp/product_info.jsp"; } }
package com.itheima.web.servlet; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.URLEncoder; import javax.servlet.ServletException; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.beanutils.BeanUtils; import com.itheima.constant.Constant; import com.itheima.domain.User; import com.itheima.service.UserService; import com.itheima.service.impl.UserServiceImpl; import com.itheima.utils.UUIDUtils; import com.itheima.web.servlet.base.BaseServlet; import com.sun.xml.internal.bind.v2.runtime.unmarshaller.InterningXmlVisitor; /** * 用戶模塊 */ public class UserServlet extends BaseServlet { private static final long serialVersionUID = 1L; /** * 退出 */ public String logout(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.getSession().invalidate(); response.sendRedirect(request.getContextPath()); return null; } /** * 用戶登陸 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String login(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //1.獲取用戶名和密碼 String username = request.getParameter("username"); String password = request.getParameter("password"); //2.調用service完成登陸 返回值:user UserService us = new UserServiceImpl(); User user=us.login(username,password); //3.判斷user 根據結果生成提示 if(user == null){ //用戶名和密碼不匹配 request.setAttribute("msg", "用戶名和密碼不匹配");; return "/jsp/login.jsp"; } //若用戶不爲空,繼續判斷是否激活 if(Constant.USER_IS_ACTIVE != user.getState()){ //未激活 request.setAttribute("msg", "請先去郵箱激活,再登陸!"); return "/jsp/msg.jsp"; } //登陸成功 保存用戶登陸狀態 request.getSession().setAttribute("user", user); /////////////////記住用戶名////////////////////// //判斷是否勾選了記住用戶名 if(Constant.SAVE_NAME.equals(request.getParameter("savename"))){ Cookie c = new Cookie("saveName", URLEncoder.encode(username, "utf-8")); c.setMaxAge(Integer.MAX_VALUE); c.setPath(request.getContextPath()+"/"); response.addCookie(c); } /////////////////////////////////////// //跳轉到 index.jsp response.sendRedirect(request.getContextPath()); } catch (Exception e) { e.printStackTrace(); request.setAttribute("msg", "用戶登陸失敗"); return "/jsp/msg.jsp"; } return null; } /** * 跳轉到登陸頁面 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String loginUI(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { return "/jsp/login.jsp"; } /** * 用戶激活 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String active(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //1.接受code String code = request.getParameter("code"); //2.調用service完成激活 返回值:user UserService us=new UserServiceImpl(); User user=us.active(code); //3.判斷user 生成不一樣的提示信息 if(user == null){ //沒有找到這個用戶,激活失敗 request.setAttribute("msg", "激活失敗,請從新激活或者從新註冊~"); return "/jsp/msg.jsp"; } //激活成功 request.setAttribute("msg", "恭喜你,激活成功了,能夠登陸了~"); } catch (Exception e) { request.setAttribute("msg", "激活失敗,請從新激活或者從新註冊~"); return "/jsp/msg.jsp"; } return "/jsp/msg.jsp"; } /** * 用戶註冊 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String regist(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //1.封裝對象 User user = new User(); BeanUtils.populate(user, request.getParameterMap()); //1.1手動封裝uid user.setUid(UUIDUtils.getId()); //1.2手動封裝激活狀態 state user.setState(Constant.USER_IS_NOT_ACTIVE); //1.3手動封裝激活碼 code user.setCode(UUIDUtils.getCode()); //2.調用service完成註冊 UserService us=new UserServiceImpl(); us.regist(user); //3.頁面轉發 提示信息 request.setAttribute("msg", "恭喜你,註冊成功,請登陸郵箱完成激活!"); }catch (Exception e) { e.printStackTrace(); //轉發到 msg.jsp request.setAttribute("msg", "用戶註冊失敗!"); return "/jsp/msg.jsp"; } return "/jsp/msg.jsp"; } /** * 跳轉到註冊頁面 * @param request * @param response * @return * @throws ServletException * @throws IOException */ public String registUI(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { return "/jsp/register.jsp"; } }
com.itheima.web.servlet.base
package com.itheima.web.servlet.base; import java.io.IOException; import java.lang.reflect.Method; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * 通用的servlet */ public class BaseServlet extends HttpServlet { private static final long serialVersionUID = 1L; protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { //1.獲取方法名稱 String mName = request.getParameter("method"); //1.1判斷 參數是否爲空 若爲空,執行默認的方法 if(mName == null || mName.trim().length()==0){ mName = "index"; } //2.獲取方法對象 Method method = this.getClass().getMethod(mName, HttpServletRequest.class,HttpServletResponse.class); //3.讓方法執行,接受返回值 String path=(String) method.invoke(this, request,response); //4.判斷返回值是否爲空 若不爲空統一處理請求轉發 if(path != null){ request.getRequestDispatcher(path).forward(request, response); } } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(); } } public String index(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException { response.setContentType("text/html;charset=utf-8"); response.getWriter().println("親,不要搗亂"); return null; } }
<?xml version="1.0" encoding="UTF-8"?> <beans> <bean id="ProductDao" class="com.itheima.dao.impl.ProductDaoImpl"/> <!-- <bean id="ProductDao" class="com.itheima.dao.impl.ProductDaoHibImpl"/> --> <bean id="UserDao" class="com.itheima.dao.impl.UserDaoImpl"/> <bean id="CategoryDao" class="com.itheima.dao.impl.CategoryDaoImpl"/> <bean id="OrderDao" class="com.itheima.dao.impl.OrderDaoImpl"/> <bean id="ProductService" class="com.itheima.service.impl.ProductServiceImpl"/> <bean id="UserService" class="com.itheima.service.impl.UserServiceImpl"/> <bean id="CategoryService" class="com.itheima.service.impl.CategoryServiceImpl"/> <bean id="OrderService" class="com.itheima.service.impl.OrderServiceImpl"/> </beans>
<?xml version="1.0" encoding="UTF-8"?> <beans> <bean id="ProductDao" class="com.itheima.dao.impl.ProductDaoImpl"/> <!-- <bean id="ProductDao" class="com.itheima.dao.impl.ProductDaoHibImpl"/> --> <bean id="UserDao" class="com.itheima.dao.impl.UserDaoImpl"/> <bean id="CategoryDao" class="com.itheima.dao.impl.CategoryDaoImpl"/> <bean id="OrderDao" class="com.itheima.dao.impl.OrderDaoImpl"/> <bean id="ProductService" class="com.itheima.service.impl.ProductServiceImpl"/> <bean id="UserService" class="com.itheima.service.impl.UserServiceImpl"/> <bean id="CategoryService" class="com.itheima.service.impl.CategoryServiceImpl"/> <bean id="OrderService" class="com.itheima.service.impl.OrderServiceImpl"/> </beans>
p1_MerId=10001126856 keyValue=69cl522AV6q613Ii4W6u8K6XuW8vM1N6bFgyv769220IuYe9u37N4y7rI4Pl responseURL=http://localhost/store/order?method=callback
後臺頁面的代碼區
<%@ page language="java" pageEncoding="UTF-8"%> <html> <head> <meta http-equiv="Content-Language" content="zh-cn"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <style type="text/css"> <!-- body { background-color: #FFFFFF; margin: 0px;} body,td,th { font-size: 12px; color: #000000; } --> </style> </HEAD> <body MS_POSITIONING="GridLayout"> <table width="100%" border="0" cellspacing="0" cellpadding="10" height="64"> <tr> <td align="center" width="100%" style= valign="top" background="${pageContext.request.contextPath}/images/bt_02.jpg">商城管理平臺 <br> <font class="font12"> <a class="a03" target="_blank" href="mailto:admin@store.com"> <font color="#000000"><br></font></a></font></td> </tr> </table> </body> </HTML>
<%@ page language="java" pageEncoding="UTF-8"%> <html> <head> <meta http-equiv="Content-Language" content="zh-cn"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <style> body { SCROLLBAR-ARROW-COLOR: #ffffff; SCROLLBAR-BASE-COLOR: #dee3f7; } </style> </head> <frameset rows="103,*,43" frameborder=0 border="0" framespacing="0"> <frame src="${pageContext.request.contextPath}/admin/top.jsp" name="topFrame" scrolling="NO" noresize> <frameset cols="159,*" frameborder="0" border="0" framespacing="0"> <frame src="${pageContext.request.contextPath}/admin/left.jsp" name="leftFrame" noresize scrolling="YES"> <frame src="${pageContext.request.contextPath}/admin/welcome.jsp" name="mainFrame"> </frameset> <frame src="${pageContext.request.contextPath}/admin/bottom.jsp" name="bottomFrame" scrolling="NO" noresize> </frameset> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>網上商城管理中心</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link href="${pageContext.request.contextPath }/css/general.css" rel="stylesheet" type="text/css" /> <link href="${pageContext.request.contextPath }/css/main.css" rel="stylesheet" type="text/css" /> <style type="text/css"> body { color: white; } </style> </head> <body style="background: #278296"> <center></center> <form method="post" action="${pageContext.request.contextPath }/admin/home.jsp" target="_parent" name='theForm' onsubmit="return validate()"> <table cellspacing="0" cellpadding="0" style="margin-top: 100px" align="center"> <tr> <td style="padding-left: 50px"> <table> <tr> <td>管理員姓名:</td> <td><input type="text" name="username" /></td> </tr> <tr> <td>管理員密碼:</td> <td><input type="password" name="password" /></td> </tr> <tr><td> </td><td><input type="submit" value="進入管理中心" class="button" /></td></tr> </table> </td> </tr> </table> </form> <script language="JavaScript"> <!-- document.forms['theForm'].elements['username'].focus(); /** * 檢查表單輸入的內容 */ function validate() { var validator = new Validator('theForm'); validator.required('username', user_name_empty); //validator.required('password', password_empty); if (document.forms['theForm'].elements['captcha']) { validator.required('captcha', captcha_empty); } return validator.passed(); } //--> </script> </body>
<%@ page language="java" pageEncoding="UTF-8"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>菜單</title> <link href="${pageContext.request.contextPath}/css/left.css" rel="stylesheet" type="text/css"/> <link rel="StyleSheet" href="${pageContext.request.contextPath}/css/dtree.css" type="text/css" /> </head> <body> <table width="100" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="12"></td> </tr> </table> <table width="100%" border="0"> <tr> <td> <div class="dtree"> <a href="javascript: d.openAll();">展開全部</a> | <a href="javascript: d.closeAll();">關閉全部</a> <script type="text/javascript" src="${pageContext.request.contextPath}/js/dtree.js"></script> <script type="text/javascript"> d = new dTree('d'); d.add('01',-1,'系統菜單樹'); d.add('0102','01','分類管理','','','mainFrame'); d.add('010201','0102','分類列表','${pageContext.request.contextPath}/adminCategory?method=findAll','','mainFrame'); d.add('010202','0102','添加分類','${pageContext.request.contextPath}/adminCategory?method=addUI','','mainFrame'); d.add('0104','01','商品管理'); d.add('010401','0104','已上架商品列表','${pageContext.request.contextPath}/adminProduct?method=findAll','','mainFrame'); d.add('010402','0104','添加商品','${pageContext.request.contextPath}/adminProduct?method=addUI','','mainFrame'); d.add('0105','01','訂單管理'); d.add('010501','0105','訂單列表','${pageContext.request.contextPath}/adminOrder?method=findAllByState','','mainFrame'); d.add('010502','0105','未付款訂單','${pageContext.request.contextPath}/adminOrder?method=findAllByState&state=0','','mainFrame'); d.add('010503','0105','已付款訂單','${pageContext.request.contextPath}/adminOrder?method=findAllByState&state=1','','mainFrame'); d.add('010504','0105','已發貨訂單','${pageContext.request.contextPath}/adminOrder?method=findAllByState&state=2','','mainFrame'); d.add('010505','0105','已完成訂單','${pageContext.request.contextPath}/adminOrder?method=findAllByState&state=3','','mainFrame'); document.write(d); </script> </div> </td> </tr> </table> </body> </html>
<%@ page language="java" pageEncoding="UTF-8"%> <html> <head> <meta http-equiv="Content-Language" content="zh-cn"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <style type="text/css"> BODY { MARGIN: 0px; BACKGROUND-COLOR: #ffffff } BODY { FONT-SIZE: 12px; COLOR: #000000 } TD { FONT-SIZE: 12px; COLOR: #000000 } TH { FONT-SIZE: 12px; COLOR: #000000 } </style> <link href="${pageContext.request.contextPath}/css/Style1.css" rel="stylesheet" type="text/css"> </HEAD> <body> <table width="100%" height="70%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <img width="100%" src="${pageContext.request.contextPath}/images/top_01.jpg"> </td> <td width="100%" background="${pageContext.request.contextPath}/images/top_100.jpg"> </td> </tr> </table> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="30" valign="bottom" background="${pageContext.request.contextPath}/images/mis_01.jpg"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="85%" align="left"> <font color="#000000"> <script language="JavaScript"> <!-- tmpDate = new Date(); date = tmpDate.getDate(); month= tmpDate.getMonth() + 1 ; year= tmpDate.getYear(); document.write(year); document.write("年"); document.write(month); document.write("月"); document.write(date); document.write("日 "); myArray=new Array(6); myArray[0]="星期日" myArray[1]="星期一" myArray[2]="星期二" myArray[3]="星期三" myArray[4]="星期四" myArray[5]="星期五" myArray[6]="星期六" weekday=tmpDate.getDay(); if (weekday==0 | weekday==6) { document.write(myArray[weekday]) } else {document.write(myArray[weekday]) }; // --> </script> </font> </td> <td width="15%"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="16" background="${pageContext.request.contextPath}/images/mis_05b.jpg"> <img src="${pageContext.request.contextPath}/images/mis_05a.jpg" width="6" height="18"> </td> <td width="155" valign="bottom" background="${pageContext.request.contextPath}/images/mis_05b.jpg"> 用戶名: <font color="blue"><s:property value="#session.existAdminUser.username"/></font> </td> <td width="10" align="right" background="${pageContext.request.contextPath}/images/mis_05b.jpg"> <img src="${pageContext.request.contextPath}/images/mis_05c.jpg" width="6" height="18"> </td> </tr> </table> </td> <td align="right" width="5%"> </td> </tr> </table> </td> </tr> </table> </body> </HTML>
<%@ page language="java" pageEncoding="UTF-8"%> <html> <head> <meta http-equiv="Content-Language" content="zh-cn"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link href="${pageContext.request.contextPath}/css/Style1.css" type="text/css" rel="stylesheet" /> <style type="text/css"> <!-- body { background-color: #FFFFFF; margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } body,td,th { color: #000000; } --> </style> <style> BODY {SCROLLBAR-FACE-COLOR: #cccccc; SCROLLBAR-HIGHLIGHT-COLOR: #ffffFF; SCROLLBAR-SHADOW-COLOR: #ffffff; SCROLLBAR-3DLIGHT-COLOR: #cccccc; SCROLLBAR-ARROW-COLOR: #ffffff; SCROLLBAR-TRACK-COLOR: #ffffFF; SCROLLBAR-DARKSHADOW-COLOR: #cccccc; } </style> </head> <body> <form name="Form1" method="post" action="name.aspx" id="Form1"> <table width="100%" border="0" height="88" border="1" background="${pageContext.request.contextPath}/images/back1.JPG"> <tr> <td colspan=3 class="ta_01" align="center" bgcolor="#afd1f3"><strong>系統首頁</strong></td> </tr> <tr> <td width="65%" height="84" align="center" valign="top" > <span class="Style1">登陸成功!</span> </td> </tr> <tr><td height=2></td></tr> </table> </form> </body> </html>
<%@ page language="java" pageEncoding="UTF-8"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <HTML> <HEAD> <meta http-equiv="Content-Language" content="zh-cn"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link href="${pageContext.request.contextPath}/css/Style1.css" rel="stylesheet" type="text/css" /> <script language="javascript" src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js"></script> <script language="javascript" src="${pageContext.request.contextPath}/layer/layer.js"></script> <script type="text/javascript"> function showDetail(oid){ //alert(oid); //發送ajax $.post("${pageContext.request.contextPath}/adminOrder",{"method":"showDetail","oid":oid},function(d){ //alert(d); var s="<table border='1' width='99%'>"; s+="<tr><th>商品名稱</th><th>購買數量</th></tr>" $(d).each(function(){ s+="<tr><td>"+this.product.pname+"</td><td>"+this.count+"</td></tr>"; }); s+="</table>"; layer.open({ type: 1,//0:信息框; 1:頁面; 2:iframe層; 3:加載層; 4:tip層 title:"訂單號:"+oid,//標題 area: ['520px', '300px'],//大小 shadeClose: true, //點擊彈層外區域 遮罩關閉 content: s//內容 }); },"json"); } </script> </HEAD> <body> <br> <form id="Form1" name="Form1" action="${pageContext.request.contextPath}/user/list.jsp" method="post"> <table cellSpacing="1" cellPadding="0" width="100%" align="center" bgColor="#f5fafe" border="0"> <TBODY> <tr> <td class="ta_01" align="center" bgColor="#afd1f3"> <strong>訂單列表</strong> </TD> </tr> <tr> <td class="ta_01" align="center" bgColor="#f5fafe"> <table cellspacing="0" cellpadding="1" rules="all" bordercolor="gray" border="1" id="DataGrid1" style="BORDER-RIGHT: gray 1px solid; BORDER-TOP: gray 1px solid; BORDER-LEFT: gray 1px solid; WIDTH: 100%; WORD-BREAK: break-all; BORDER-BOTTOM: gray 1px solid; BORDER-COLLAPSE: collapse; BACKGROUND-COLOR: #f5fafe; WORD-WRAP: break-word"> <tr style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; HEIGHT: 25px; BACKGROUND-COLOR: #afd1f3"> <td align="center" width="10%"> 序號 </td> <td align="center" width="10%"> 訂單編號 </td> <td align="center" width="10%"> 訂單金額 </td> <td align="center" width="10%"> 收貨人 </td> <td align="center" width="10%"> 訂單狀態 </td> <td align="center" width="50%"> 訂單詳情 </td> </tr> <c:forEach items="${list }" var="o" varStatus="vs"> <tr onmouseover="this.style.backgroundColor = 'white'" onmouseout="this.style.backgroundColor = '#F5FAFE';"> <td style="CURSOR: hand; HEIGHT: 22px" align="center" width="18%"> ${vs.count } </td> <td style="CURSOR: hand; HEIGHT: 22px" align="center" width="17%"> ${o.oid } </td> <td style="CURSOR: hand; HEIGHT: 22px" align="center" width="17%"> ${o.total } </td> <td style="CURSOR: hand; HEIGHT: 22px" align="center" width="17%"> ${o.name } </td> <td style="CURSOR: hand; HEIGHT: 22px" align="center" width="17%"> <c:if test="${o.state == 0 }">未付款</c:if> <c:if test="${o.state == 1 }"> <a href="${pageContext.request.contextPath }/adminOrder?method=updateState&oid=${o.oid}">去發貨</a> </c:if> <c:if test="${o.state == 2 }">待收貨</c:if> <c:if test="${o.state == 3 }">已完成</c:if> </td> <td align="center" style="HEIGHT: 22px"> <input type="button" value="訂單詳情" onclick="showDetail('${o.oid}')"/> </td> </tr> </c:forEach> </table> </td> </tr> </TBODY> </table> </form> </body> </HTML>
前臺頁面的代碼區
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!doctype html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>會員登陸</title> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css" type="text/css" /> <script src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js" type="text/javascript"></script> <script src="${pageContext.request.contextPath}/js/bootstrap.min.js" type="text/javascript"></script> <!-- 引入自定義css文件 style.css --> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" type="text/css" /> <style> body { margin-top: 20px; margin: 0 auto; } .carousel-inner .item img { width: 100%; height: 300px; } .container .row div { /* position:relative; float:left; */ } font { color: #3164af; font-size: 18px; font-weight: normal; padding: 0 10px; } </style> </head> <body> <%@include file="/jsp/head.jsp" %> <div class="container"> <div class="row"> <c:if test="${empty cart || empty cart.cartItems }"> <h3>購物車空空如也,親,請先去逛逛去吧~~~~~~~~~~~</h3> </c:if> <c:if test="${not empty cart.cartItems}"> <div style="margin:0 auto; margin-top:10px;width:950px;"> <strong style="font-size:16px;margin:5px 0;">購物車詳情</strong> <table class="table table-bordered"> <tbody> <tr class="warning"> <th>圖片</th> <th>商品</th> <th>價格</th> <th>數量</th> <th>小計</th> <th>操做</th> </tr> <c:forEach items="${cart.cartItems }" var="ci"> <tr class="active"> <td width="60" width="40%"> <input type="hidden" name="id" value="22"> <img src="${pageContext.request.contextPath}/${ci.product.pimage}" width="70" height="60"> </td> <td width="30%"> <a target="_blank">${ci.product.pname}</a> </td> <td width="20%"> ¥${ci.product.shop_price} </td> <td width="10%"> <input type="text" readonly="readonly" name="quantity" value="${ci.count }" maxlength="4" size="10"> </td> <td width="15%"> <span class="subtotal">¥${ci.subtotal }</span> </td> <td> <a href="javascript:void(0);" onclick="removeFromCart('${ci.product.pid}')" class="delete">刪除</a> </td> </tr> </c:forEach> </tbody> </table> </div> </div> <div style="margin-right:130px;"> <div style="text-align:right;"> 商品金額: <strong style="color:#ff6600;">¥${cart.total }元</strong> </div> <div style="text-align:right;margin-top:10px;margin-bottom:10px;"> <a href="${pageContext.request.contextPath }/cart?method=clear" id="clear" class="clear">清空購物車</a> <a href="${pageContext.request.contextPath }/order?method=save"> <input type="button" width="100" value="提交訂單" name="submit" border="0" style="background: url('${pageContext.request.contextPath}/images/register.gif') no-repeat scroll 0 0 rgba(0, 0, 0, 0); height:35px;width:100px;color:white;"> </a> </div> </div> </c:if> </div> <div style="margin-top:50px;"> <img src="${pageContext.request.contextPath}/image/footer.jpg" width="100%" height="78" alt="咱們的優點" title="咱們的優點" /> </div> <div style="text-align: center;margin-top: 5px;"> <ul class="list-inline"> <li><a>關於咱們</a></li> <li><a>聯繫咱們</a></li> <li><a>招賢納士</a></li> <li><a>法律聲明</a></li> <li><a>友情連接</a></li> <li><a target="_blank">支付方式</a></li> <li><a target="_blank">配送方式</a></li> <li><a>服務聲明</a></li> <li><a>廣告聲明</a></li> </ul> </div> <div style="text-align: center;margin-top: 5px;margin-bottom:20px;"> Copyright © 2005-2016 傳智商城 版權全部 </div> </body> <script type="text/javascript"> function removeFromCart(pid){ if(confirm("您忍心拋棄我嗎?")){ location.href="${pageContext.request.contextPath}/cart?method=remove&pid="+pid; } } </script> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!-- 時間:2015-12-30 描述:菜單欄 --> <div class="container-fluid"> <div class="col-md-4"> <img src="${pageContext.request.contextPath}/img/logo2.png" /> </div> <div class="col-md-5"> <img src="${pageContext.request.contextPath}/img/header.png" /> </div> <div class="col-md-3" style="padding-top:20px"> <ol class="list-inline"> <c:if test="${empty user }"> <li><a href="${pageContext.request.contextPath }/user?method=loginUI">登陸</a></li> <li><a href="${pageContext.request.contextPath }/user?method=registUI">註冊</a></li> </c:if> <c:if test="${not empty user }"> ${user.name }:你好! <li><a href="${pageContext.request.contextPath }/order?method=findMyOrdersByPage&pageNumber=1">個人訂單</a></li> <li><a href="${pageContext.request.contextPath }/user?method=logout">退出</a></li> </c:if> <li><a href="${pageContext.request.contextPath }/jsp/cart.jsp">購物車</a></li> </ol> </div> </div> <!-- 時間:2015-12-30 描述:導航條 --> <div class="container-fluid"> <nav class="navbar navbar-inverse"> <div class="container-fluid"> <!-- Brand and toggle get grouped for better mobile display --> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="${pageContext.request.contextPath }">首頁</a> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav" id="c_ul"> </ul> <form class="navbar-form navbar-right" role="search"> <div class="form-group"> <input type="text" class="form-control" placeholder="Search"> </div> <button type="submit" class="btn btn-default">Submit</button> </form> </div> <!-- /.navbar-collapse --> </div> <!-- /.container-fluid --> </nav> </div> <script type="text/javascript"> $(function(){ //發送ajax 查詢全部分類 $.post("${pageContext.request.contextPath}/category",{"method":"findAll"},function(obj){ //alert(obj); //遍歷json列表,獲取每個分類,包裝成li標籤,插入到ul內部 //$.each($(obj),function(){}); $(obj).each(function(){ //alert(this.cname); $("#c_ul").append("<li><a href='${pageContext.request.contextPath}/product?method=findByPage&pageNumber=1&cid="+this.cid+"'>"+this.cname+"</a></li>"); }); },"json"); }) </script>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>WEB01</title> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css" type="text/css" /> <script src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js" type="text/javascript"></script> <script src="${pageContext.request.contextPath}/js/bootstrap.min.js" type="text/javascript"></script> </head> <body> <div class="container-fluid"> <%@include file="/jsp/head.jsp" %> <!-- 做者:ci2713@163.com 時間:2015-12-30 描述:輪播條 --> <div class="container-fluid"> <div id="carousel-example-generic" class="carousel slide" data-ride="carousel"> <!-- Indicators --> <ol class="carousel-indicators"> <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li> <li data-target="#carousel-example-generic" data-slide-to="1"></li> <li data-target="#carousel-example-generic" data-slide-to="2"></li> </ol> <!-- Wrapper for slides --> <div class="carousel-inner" role="listbox"> <div class="item active"> <img src="${pageContext.request.contextPath}/img/1.jpg"> <div class="carousel-caption"> </div> </div> <div class="item"> <img src="${pageContext.request.contextPath}/img/2.jpg"> <div class="carousel-caption"> </div> </div> <div class="item"> <img src="${pageContext.request.contextPath}/img/3.jpg"> <div class="carousel-caption"> </div> </div> </div> <!-- Controls --> <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next"> <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div> </div> <!-- 做者:ci2713@163.com 時間:2015-12-30 描述:商品顯示 --> <div class="container-fluid"> <div class="col-md-12"> <h2>熱門商品 <img src="${pageContext.request.contextPath}/img/title2.jpg"/></h2> </div> <div class="col-md-2" style="border:1px solid #E7E7E7;border-right:0;padding:0;"> <img src="${pageContext.request.contextPath}/products/hao/big01.jpg" width="205" height="404" style="display: inline-block;"/> </div> <div class="col-md-10"> <div class="col-md-6" style="text-align:center;height:200px;padding:0px;"> <a href="product_info.htm"> <img src="${pageContext.request.contextPath}/products/hao/middle01.jpg" width="516px" height="200px" style="display: inline-block;"> </a> </div> <c:forEach items="${hList }" var="p"> <div class="col-md-2" style="text-align:center;height:200px;padding:10px 0px;"> <a href="${pageContext.request.contextPath }/product?method=getById&pid=${p.pid}"> <img src="${pageContext.request.contextPath}/${p.pimage}" width="130" height="130" style="display: inline-block;"> </a> <p><a href="${pageContext.request.contextPath }/product?method=getById&pid=${p.pid}" style='color:#666'>${fn:substring(p.pname,0,10) }..</a></p> <p><font color="#E4393C" style="font-size:16px">¥${p.shop_price }</font></p> </div> </c:forEach> </div> </div> <!-- 做者:ci2713@163.com 時間:2015-12-30 描述:廣告部分 --> <div class="container-fluid"> <img src="${pageContext.request.contextPath}/products/hao/ad.jpg" width="100%"/> </div> <!-- 做者:ci2713@163.com 時間:2015-12-30 描述:商品顯示 --> <div class="container-fluid"> <div class="col-md-12"> <h2>最新商品 <img src="${pageContext.request.contextPath}/img/title2.jpg"/></h2> </div> <div class="col-md-2" style="border:1px solid #E7E7E7;border-right:0;padding:0;"> <img src="${pageContext.request.contextPath}/products/hao/big01.jpg" width="205" height="404" style="display: inline-block;"/> </div> <div class="col-md-10"> <div class="col-md-6" style="text-align:center;height:200px;padding:0px;"> <a href="product_info.htm"> <img src="${pageContext.request.contextPath}/products/hao/middle01.jpg" width="516px" height="200px" style="display: inline-block;"> </a> </div> <c:forEach items="${nList }" var="p"> <div class="col-md-2" style="text-align:center;height:200px;padding:10px 0px;"> <a href="${pageContext.request.contextPath }/product?method=getById&pid=${p.pid}"> <img src="${pageContext.request.contextPath}/${p.pimage}" width="130" height="130" style="display: inline-block;"> </a> <p><a href="${pageContext.request.contextPath }/product?method=getById&pid=${p.pid}" style='color:#666'>${fn:substring(p.pname,0,10) }..</a></p> <p><font color="#E4393C" style="font-size:16px">¥${p.shop_price }</font></p> </div> </c:forEach> </div> </div> <!-- 做者:ci2713@163.com 時間:2015-12-30 描述:頁腳部分 --> <div class="container-fluid"> <div style="margin-top:50px;"> <img src="${pageContext.request.contextPath}/img/footer.jpg" width="100%" height="78" alt="咱們的優點" title="咱們的優點" /> </div> <div style="text-align: center;margin-top: 5px;"> <ul class="list-inline"> <li><a href="info.html">關於咱們</a></li> <li><a>聯繫咱們</a></li> <li><a>招賢納士</a></li> <li><a>法律聲明</a></li> <li><a>友情連接</a></li> <li><a>支付方式</a></li> <li><a>配送方式</a></li> <li><a>服務聲明</a></li> <li><a>廣告聲明</a></li> </ul> </div> <div style="text-align: center;margin-top: 5px;margin-bottom:20px;"> Copyright © 2005-2016 傳智商城 版權全部 </div> </div> </div> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>WEB01</title> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css" type="text/css" /> <script src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js" type="text/javascript"></script> <script src="${pageContext.request.contextPath}/js/bootstrap.min.js" type="text/javascript"></script> </head> <body> <div class="container-fluid"> <!-- 時間:2015-12-30 描述:菜單欄 --> <div class="container-fluid"> <div class="col-md-4"> <img src="${pageContext.request.contextPath}/img/logo2.png" /> </div> <div class="col-md-5"> <img src="${pageContext.request.contextPath}/img/header.png" /> </div> <div class="col-md-3" style="padding-top:20px"> <ol class="list-inline"> <li><a href="">登陸</a></li> <li><a href="">註冊</a></li> <li><a href="">購物車</a></li> </ol> </div> </div> <!-- 時間:2015-12-30 描述:導航條 --> <div class="container-fluid"> <nav class="navbar navbar-inverse"> <div class="container-fluid"> <!-- Brand and toggle get grouped for better mobile display --> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">首頁</a> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li class="active"><a href="#">手機數碼<span class="sr-only">(current)</span></a></li> <li><a href="#">電腦辦公</a></li> <li><a href="#">電腦辦公</a></li> <li><a href="#">電腦辦公</a></li> </ul> <form class="navbar-form navbar-right" role="search"> <div class="form-group"> <input type="text" class="form-control" placeholder="Search"> </div> <button type="submit" class="btn btn-default">Submit</button> </form> </div> <!-- /.navbar-collapse --> </div> <!-- /.container-fluid --> </nav> </div> <div class="container-fluid"> <div class="main_con"> <h2>公司簡介</h2> <hr/> <div> <p> <font color="red">「中關村黑馬程序員訓練營」</font>是由傳智播客聯合中關村軟件園、CSDN,並委託傳智播客進行教學實施的軟件開發高端培訓機構,致力於服務各大軟件企業,解決當前軟件開發技術飛速發展,而企業招不到優秀人才的困擾。 目前,「中關村黑馬程序員訓練營」已成長爲行業「學員質量好、課程內容深、企業滿意」的移動開發高端訓練基地,並被評爲中關村軟件園重點扶持人才企業。 </p> <p> 黑馬程序員的學員多爲大學畢業後,有理想、有夢想,想從事IT行業,而沒有環境和機遇改變本身命運的年輕人。黑馬程序員的學員篩選制度,遠比如今90%以上的企業招聘流程更爲嚴格。任何一名學員想成功入學「黑馬程序員」,必須經歷長達2個月的面試流程,這些流程中不只包括嚴格的技術測試、自學能力測試,還包括性格測試、壓力測試、品德測試等等測試。絕不誇張地說,黑馬程序員訓練營全部學員都是精挑細選出來的。鳳毛麟角的殘酷篩選制度確保學員質量,並下降企業的用人風險。 </p> <p> 中關村黑馬程序員訓練營不只着重培養學員的基礎理論知識,更注重培養項目實施管理能力,並密切關注技術革新,不斷引入先進的技術,研發更新技術課程,確保學員進入企業後不只能獨立從事開發工做,更能給企業帶來新的技術體系和理念。 </p> <p> 一直以來,黑馬程序員以技術視角關注IT產業發展,以深度分享推動產業技術成長,致力於弘揚技術創新,倡導分享、 開放和協做,努力打造高質量的IT人才服務平臺。 </p> </div> </div> </div> </div> <div class="container-fluid"> <div style="margin-top:50px;"> <img src="${pageContext.request.contextPath}/img/footer.jpg" width="100%" height="78" alt="咱們的優點" title="咱們的優點" /> </div> <div style="text-align: center;margin-top: 5px;"> <ul class="list-inline"> <li><a href="info.html">關於咱們</a></li> <li><a>聯繫咱們</a></li> <li><a>招賢納士</a></li> <li><a>法律聲明</a></li> <li><a>友情連接</a></li> <li><a>支付方式</a></li> <li><a>配送方式</a></li> <li><a>服務聲明</a></li> <li><a>廣告聲明</a></li> </ul> </div> <div style="text-align: center;margin-top: 5px;margin-bottom:20px;"> Copyright © 2005-2016 傳智商城 版權全部 </div> </div> </div> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!doctype html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>會員登陸</title> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css" type="text/css" /> <script src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js" type="text/javascript"></script> <script src="${pageContext.request.contextPath}/js/bootstrap.min.js" type="text/javascript"></script> <!-- 引入自定義css文件 style.css --> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" type="text/css"/> <style> body{ margin-top:20px; margin:0 auto; } .carousel-inner .item img{ width:100%; height:300px; } .container .row div{ /* position:relative; float:left; */ } font { color: #666; font-size: 22px; font-weight: normal; padding-right:17px; } </style> </head> <body> <!-- 時間:2015-12-30 描述:菜單欄 --> <div class="container-fluid"> <div class="col-md-4"> <img src="${pageContext.request.contextPath}/img/logo2.png" /> </div> <div class="col-md-5"> <img src="${pageContext.request.contextPath}/img/header.png" /> </div> <div class="col-md-3" style="padding-top:20px"> <ol class="list-inline"> <li><a href="login.htm">登陸</a></li> <li><a href="register.htm">註冊</a></li> <li><a href="cart.htm">購物車</a></li> </ol> </div> </div> <!-- 時間:2015-12-30 描述:導航條 --> <div class="container-fluid"> <nav class="navbar navbar-inverse"> <div class="container-fluid"> <!-- Brand and toggle get grouped for better mobile display --> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">首頁</a> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li class="active"><a href="#">手機數碼<span class="sr-only">(current)</span></a></li> <li><a href="#">電腦辦公</a></li> <li><a href="#">電腦辦公</a></li> <li><a href="#">電腦辦公</a></li> </ul> <form class="navbar-form navbar-right" role="search"> <div class="form-group"> <input type="text" class="form-control" placeholder="Search"> </div> <button type="submit" class="btn btn-default">Submit</button> </form> </div> <!-- /.navbar-collapse --> </div> <!-- /.container-fluid --> </nav> </div> <div class="container" style="width:100%;height:460px;background:#FF2C4C url('${pageContext.request.contextPath}/images/loginbg.jpg') no-repeat;"> <div class="row"> <div class="col-md-7"> <!--<img src="${pageContext.request.contextPath}/image/login.jpg" width="500" height="330" alt="會員登陸" title="會員登陸">--> </div> <div class="col-md-5"> <div style="width:440px;border:1px solid #E7E7E7;padding:20px 0 20px 30px;border-radius:5px;margin-top:60px;background:#fff;"> <font>會員登陸</font>USER LOGIN ${msg } <div> </div> <form class="form-horizontal" action="${pageContext.request.contextPath }/user" method="post"> <input type="hidden" name="method" value="login"> <div class="form-group"> <label for="username" class="col-sm-2 control-label">用戶名</label> <div class="col-sm-6"> <input type="text" class="form-control" id="username" placeholder="請輸入用戶名" name="username"> </div> </div> <div class="form-group"> <label for="inputPassword3" class="col-sm-2 control-label">密碼</label> <div class="col-sm-6"> <input type="password" class="form-control" id="inputPassword3" placeholder="請輸入密碼" name="password"> </div> </div> <div class="form-group"> <label for="inputPassword3" class="col-sm-2 control-label">驗證碼</label> <div class="col-sm-3"> <input type="text" class="form-control" id="inputPassword3" placeholder="請輸入驗證碼"> </div> <div class="col-sm-3"> <img src="${pageContext.request.contextPath}/image/captcha.jhtml"/> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <div class="checkbox"> <label> <input type="checkbox"> 自動登陸 </label> <label> <input type="checkbox" name="savename" value="ok"> 記住用戶名 </label> </div> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <input type="submit" width="100" value="登陸" name="submit" border="0" style="background: url('${pageContext.request.contextPath}/images/login.gif') no-repeat scroll 0 0 rgba(0, 0, 0, 0); height:35px;width:100px;color:white;"> </div> </div> </form> </div> </div> </div> </div> <div style="margin-top:50px;"> <img src="${pageContext.request.contextPath}/image/footer.jpg" width="100%" height="78" alt="咱們的優點" title="咱們的優點" /> </div> <div style="text-align: center;margin-top: 5px;"> <ul class="list-inline"> <li><a>關於咱們</a></li> <li><a>聯繫咱們</a></li> <li><a>招賢納士</a></li> <li><a>法律聲明</a></li> <li><a>友情連接</a></li> <li><a target="_blank">支付方式</a></li> <li><a target="_blank">配送方式</a></li> <li><a>服務聲明</a></li> <li><a>廣告聲明</a></li> </ul> </div> <div style="text-align: center;margin-top: 5px;margin-bottom:20px;"> Copyright © 2005-2016 傳智商城 版權全部 </div> </body> <script type="text/javascript"> var val = "${cookie.saveName.value}"; document.getElementById("username").value=decodeURI(val); </script> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>WEB01</title> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css" type="text/css" /> <script src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js" type="text/javascript"></script> <script src="${pageContext.request.contextPath}/js/bootstrap.min.js" type="text/javascript"></script> </head> <body> <div class="container-fluid"> <!-- 時間:2015-12-30 描述:菜單欄 --> <div class="container-fluid"> <div class="col-md-4"> <img src="${pageContext.request.contextPath}/img/logo2.png" /> </div> <div class="col-md-5"> <img src="${pageContext.request.contextPath}/img/header.png" /> </div> <div class="col-md-3" style="padding-top:20px"> <ol class="list-inline"> <li><a href="">登陸</a></li> <li><a href="">註冊</a></li> <li><a href="">購物車</a></li> </ol> </div> </div> <!-- 時間:2015-12-30 描述:導航條 --> <div class="container-fluid"> <nav class="navbar navbar-inverse"> <div class="container-fluid"> <!-- Brand and toggle get grouped for better mobile display --> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">首頁</a> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li class="active"><a href="#">手機數碼<span class="sr-only">(current)</span></a></li> <li><a href="#">電腦辦公</a></li> <li><a href="#">電腦辦公</a></li> <li><a href="#">電腦辦公</a></li> </ul> <form class="navbar-form navbar-right" role="search"> <div class="form-group"> <input type="text" class="form-control" placeholder="Search"> </div> <button type="submit" class="btn btn-default">Submit</button> </form> </div> <!-- /.navbar-collapse --> </div> <!-- /.container-fluid --> </nav> </div> <div class="container-fluid"> <h3>${msg }</h3> </div> </div> <div class="container-fluid"> <div style="margin-top:50px;"> <img src="${pageContext.request.contextPath}/img/footer.jpg" width="100%" height="78" alt="咱們的優點" title="咱們的優點" /> </div> <div style="text-align: center;margin-top: 5px;"> <ul class="list-inline"> <li><a href="info.html">關於咱們</a></li> <li><a>聯繫咱們</a></li> <li><a>招賢納士</a></li> <li><a>法律聲明</a></li> <li><a>友情連接</a></li> <li><a>支付方式</a></li> <li><a>配送方式</a></li> <li><a>服務聲明</a></li> <li><a>廣告聲明</a></li> </ul> </div> <div style="text-align: center;margin-top: 5px;margin-bottom:20px;"> Copyright © 2005-2016 傳智商城 版權全部 </div> </div> </div> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <!doctype html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>會員登陸</title> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css" type="text/css" /> <script src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js" type="text/javascript"></script> <script src="${pageContext.request.contextPath}/js/bootstrap.min.js" type="text/javascript"></script> <!-- 引入自定義css文件 style.css --> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" type="text/css" /> <style> body { margin-top: 20px; margin: 0 auto; } .carousel-inner .item img { width: 100%; height: 300px; } </style> </head> <body> <%@include file="/jsp/head.jsp" %> <div class="container"> <div class="row"> <div style="margin:0 auto;margin-top:10px;width:950px;"> <strong>訂單詳情</strong> <table class="table table-bordered"> <tbody> <tr class="warning"> <th colspan="2">訂單編號:${bean.oid } </th> <th colspan="1"> <c:if test="${bean.state == 0 }">去付款</c:if> <c:if test="${bean.state == 1 }">已付款</c:if> <c:if test="${bean.state == 2 }">確認收貨</c:if> <c:if test="${bean.state == 3 }">已完成</c:if> </th> <th colspan="2">時間:<fmt:formatDate value="${bean.ordertime }" pattern="yyyy-MM-dd HH:mm:ss"/> </th> </tr> <tr class="warning"> <th>圖片</th> <th>商品</th> <th>價格</th> <th>數量</th> <th>小計</th> </tr> <c:forEach items="${bean.items }" var="oi"> <tr class="active"> <td width="60" width="40%"> <input type="hidden" name="id" value="22"> <img src="${pageContext.request.contextPath}/${oi.product.pimage}" width="70" height="60"> </td> <td width="30%"> <a target="_blank">${oi.product.pname}</a> </td> <td width="20%"> ¥${oi.product.shop_price} </td> <td width="10%"> ${oi.count} </td> <td width="15%"> <span class="subtotal">¥${oi.subtotal}</span> </td> </tr> </c:forEach> </tbody> </table> </div> <div style="text-align:right;margin-right:120px;"> 商品金額: <strong style="color:#ff6600;">¥${bean.total }元</strong> </div> </div> <div> <hr/> <form action="${pageContext.request.contextPath }/order" id="orderForm" method="post" class="form-horizontal" style="margin-top:5px;margin-left:150px;"> <!-- 提交的方法 --> <input type="hidden" name="method" value="pay"> <!-- 訂單號 --> <input type="hidden" name="oid" value="${bean.oid }"> <div class="form-group"> <label for="username" class="col-sm-1 control-label">地址</label> <div class="col-sm-5"> <input type="text" name="address" class="form-control" id="username" placeholder="請輸入收貨地址"> </div> </div> <div class="form-group"> <label for="inputPassword3" class="col-sm-1 control-label">收貨人</label> <div class="col-sm-5"> <input type="text" name="name" class="form-control" id="inputPassword3" placeholder="請輸收貨人"> </div> </div> <div class="form-group"> <label for="confirmpwd" class="col-sm-1 control-label">電話</label> <div class="col-sm-5"> <input type="text" name="telephone" class="form-control" id="confirmpwd" placeholder="請輸入聯繫方式"> </div> </div> <hr/> <div style="margin-top:5px;margin-left:150px;"> <strong>選擇銀行:</strong> <p> <br/> <input type="radio" name="pd_FrpId" value="ICBC-NET-B2C" checked="checked" />工商銀行 <img src="${pageContext.request.contextPath}/bank_img/icbc.bmp" align="middle" /> <input type="radio" name="pd_FrpId" value="BOC-NET-B2C" />中國銀行 <img src="${pageContext.request.contextPath}/bank_img/bc.bmp" align="middle" /> <input type="radio" name="pd_FrpId" value="ABC-NET-B2C" />農業銀行 <img src="${pageContext.request.contextPath}/bank_img/abc.bmp" align="middle" /> <br/> <br/> <input type="radio" name="pd_FrpId" value="BOCO-NET-B2C" />交通銀行 <img src="${pageContext.request.contextPath}/bank_img/bcc.bmp" align="middle" /> <input type="radio" name="pd_FrpId" value="PINGANBANK-NET" />平安銀行 <img src="${pageContext.request.contextPath}/bank_img/pingan.bmp" align="middle" /> <input type="radio" name="pd_FrpId" value="CCB-NET-B2C" />建設銀行 <img src="${pageContext.request.contextPath}/bank_img/ccb.bmp" align="middle" /> <br/> <br/> <input type="radio" name="pd_FrpId" value="CEB-NET-B2C" />光大銀行 <img src="${pageContext.request.contextPath}/bank_img/guangda.bmp" align="middle" /> <input type="radio" name="pd_FrpId" value="CMBCHINA-NET-B2C" />招商銀行 <img src="${pageContext.request.contextPath}/bank_img/cmb.bmp" align="middle" /> </p> <hr/> <p style="text-align:right;margin-right:100px;"> <a href="javascript:document.getElementById('orderForm').submit();"> <img src="${pageContext.request.contextPath}/images/finalbutton.gif" width="204" height="51" border="0" /> </a> </p> <hr/> </div> </div> </form> </div> <div style="margin-top:50px;"> <img src="${pageContext.request.contextPath}/image/footer.jpg" width="100%" height="78" alt="咱們的優點" title="咱們的優點" /> </div> <div style="text-align: center;margin-top: 5px;"> <ul class="list-inline"> <li><a>關於咱們</a></li> <li><a>聯繫咱們</a></li> <li><a>招賢納士</a></li> <li><a>法律聲明</a></li> <li><a>友情連接</a></li> <li><a target="_blank">支付方式</a></li> <li><a target="_blank">配送方式</a></li> <li><a>服務聲明</a></li> <li><a>廣告聲明</a></li> </ul> </div> <div style="text-align: center;margin-top: 5px;margin-bottom:20px;"> Copyright © 2005-2016 傳智商城 版權全部 </div> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!doctype html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>會員登陸</title> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css" type="text/css" /> <script src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js" type="text/javascript"></script> <script src="${pageContext.request.contextPath}/js/bootstrap.min.js" type="text/javascript"></script> <!-- 引入自定義css文件 style.css --> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" type="text/css" /> <style> body { margin-top: 20px; margin: 0 auto; } .carousel-inner .item img { width: 100%; height: 300px; } </style> </head> <body> <%@include file="/jsp/head.jsp" %> <div class="container"> <div class="row"> <div style="margin:0 auto; margin-top:10px;width:950px;"> <strong>個人訂單</strong> <table class="table table-bordered"> <c:forEach items="${pb.data }" var="o"> <tbody> <tr class="success"> <th colspan="2">訂單編號:${o.oid } </th> <th colspan="1"> <c:if test="${o.state == 0 }"><a href="${pageContext.request.contextPath }/order?method=getById&oid=${o.oid}">去付款</a></c:if> <c:if test="${o.state == 1 }">已付款</c:if> <c:if test="${o.state == 2 }">確認收貨</c:if> <c:if test="${o.state == 3 }">已完成</c:if> </th> <th colspan="2">金額:${o.total }元 </th> </tr> <tr class="warning"> <th>圖片</th> <th>商品</th> <th>價格</th> <th>數量</th> <th>小計</th> </tr> <c:forEach items="${o.items }" var="oi"> <tr class="active"> <td width="60" width="40%"> <input type="hidden" name="id" value="22"> <img src="${pageContext.request.contextPath}/${oi.product.pimage}" width="70" height="60"> </td> <td width="30%"> <a target="_blank">${oi.product.pname}</a> </td> <td width="20%"> ¥${oi.product.shop_price} </td> <td width="10%"> ${oi.count } </td> <td width="15%"> <span class="subtotal">¥${oi.subtotal }</span> </td> </tr> </c:forEach> </tbody> </c:forEach> </table> </div> </div> <%@include file="/jsp/page.jsp" %> </div> <div style="margin-top:50px;"> <img src="${pageContext.request.contextPath}/image/footer.jpg" width="100%" height="78" alt="咱們的優點" title="咱們的優點" /> </div> <div style="text-align: center;margin-top: 5px;"> <ul class="list-inline"> <li><a>關於咱們</a></li> <li><a>聯繫咱們</a></li> <li><a>招賢納士</a></li> <li><a>法律聲明</a></li> <li><a>友情連接</a></li> <li><a target="_blank">支付方式</a></li> <li><a target="_blank">配送方式</a></li> <li><a>服務聲明</a></li> <li><a>廣告聲明</a></li> </ul> </div> <div style="text-align: center;margin-top: 5px;margin-bottom:20px;"> Copyright © 2005-2016 傳智商城 版權全部 </div> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!--分頁 --> <div style="width:380px;margin:0 auto;margin-top:50px;"> <ul class="pagination" style="text-align:center; margin-top:10px;"> <!-- 判斷是不是第一頁 --> <c:if test="${pb.pageNumber == 1 }"> <li class="disabled"> <a href="javascript:void(0)" aria-label="Previous"> <span aria-hidden="true">«</span> </a> </li> </c:if> <!-- 不是第一頁 --> <c:if test="${pb.pageNumber != 1 }"> <li> <a href="${pageContext.request.contextPath }/order?method=findMyOrdersByPage&pageNumber=${pb.pageNumber-1}&cid=${param.cid}" aria-label="Previous"> <span aria-hidden="true">«</span> </a> </li> </c:if> <!-- 展現全部頁碼 --> <c:forEach begin="1" end="${pb.totalPage }" var = "n"> <!-- 判斷是不是當前頁 --> <c:if test="${pb.pageNumber == n }"> <li class="active"><a href="javascript:void(0)">${n }</a></li> </c:if> <c:if test="${pb.pageNumber != n }"> <li><a href="${pageContext.request.contextPath }/order?method=findMyOrdersByPage&cid=${param.cid}&pageNumber=${n}">${n }</a></li> </c:if> </c:forEach> <!-- 判斷是不是最後一頁 --> <c:if test="${pb.pageNumber == pb.totalPage }"> <li class="disabled"> <a href="javascript:void(0)" aria-label="Next"> <span aria-hidden="true">»</span> </a> </li> </c:if> <c:if test="${pb.pageNumber != pb.totalPage }"> <li> <a href="${pageContext.request.contextPath }/order?method=findMyOrdersByPage&cid=${param.cid}&pageNumber=${pb.pageNumber+1}" aria-label="Next"> <span aria-hidden="true">»</span> </a> </li> </c:if> </ul> </div> <!-- 分頁結束======================= -->
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!doctype html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>會員登陸</title> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css" type="text/css" /> <script src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js" type="text/javascript"></script> <script src="${pageContext.request.contextPath}/js/bootstrap.min.js" type="text/javascript"></script> <!-- 引入自定義css文件 style.css --> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" type="text/css" /> <style> body { margin-top: 20px; margin: 0 auto; } .carousel-inner .item img { width: 100%; height: 300px; } </style> </head> <body> <%@include file="/jsp/head.jsp" %> <div class="container"> <div class="row"> <div style="border: 1px solid #e4e4e4;width:930px;margin-bottom:10px;margin:0 auto;padding:10px;margin-bottom:10px;"> <a href="./index.htm">首頁 ></a> <a href="./蔬菜分類.htm">蔬菜 ></a> <a>無公害蔬菜</a> </div> <div style="margin:0 auto;width:950px;"> <div class="col-md-6"> <img style="opacity: 1;width:400px;height:350px;" title="" class="medium" src="${pageContext.request.contextPath}/${bean.pimage}"> </div> <div class="col-md-6"> <div><strong>${bean.pname }</strong></div> <div style="border-bottom: 1px dotted #dddddd;width:350px;margin:10px 0 10px 0;"> <div>編號:${bean.pid }</div> </div> <div style="margin:10px 0 10px 0;">商城價: <strong style="color:#ef0101;">¥:${bean.shop_price }元</strong> 市場 價: <del>¥${bean.market_price }元</del> </div> <div style="margin:10px 0 10px 0;">促銷: <a target="_blank" title="限時搶購 (2014-07-30 ~ 2015-01-01)" style="background-color: #f07373;">限時搶購</a> </div> <div style="padding:10px;border:1px solid #e7dbb1;width:330px;margin:15px 0 10px 0;;background-color: #fffee6;"> <div style="margin:5px 0 10px 0;">白色</div> <form action="${pageContext.request.contextPath }/cart" id="form1" method="get"> <!-- 提交的方法 --> <input type="hidden" name="method" value="add2cart"> <!-- 商品的pid --> <input type="hidden" name="pid" value="${bean.pid }"> <div style="border-bottom: 1px solid #faeac7;margin-top:20px;padding-left: 10px;">購買數量: <input id="quantity" name="count" value="1" maxlength="4" size="10" type="text"> </div> <div style="margin:20px 0 10px 0;;text-align: center;"> </form> <a href="javascript:void(0)" onclick="subForm()"> <input style="background: url('${pageContext.request.contextPath}/images/product.gif') no-repeat scroll 0 -600px rgba(0, 0, 0, 0);height:36px;width:127px;" value="加入購物車" type="button"> </a> 收藏商品</div> </div> </div> </div> <div class="clear"></div> <div style="width:950px;margin:0 auto;"> <div style="background-color:#d3d3d3;width:930px;padding:10px 10px;margin:10px 0 10px 0;"> <strong>商品介紹</strong> </div> <div> <img src="${pageContext.request.contextPath}/${bean.pimage}"> </div> <div style="background-color:#d3d3d3;width:930px;padding:10px 10px;margin:10px 0 10px 0;"> <strong>${bean.pdesc }</strong> </div> </div> </div> <div style="margin-top:50px;"> <img src="${pageContext.request.contextPath}/image/footer.jpg" width="100%" height="78" alt="咱們的優點" title="咱們的優點" /> </div> <div style="text-align: center;margin-top: 5px;"> <ul class="list-inline"> <li><a>關於咱們</a></li> <li><a>聯繫咱們</a></li> <li><a>招賢納士</a></li> <li><a>法律聲明</a></li> <li><a>友情連接</a></li> <li><a target="_blank">支付方式</a></li> <li><a target="_blank">配送方式</a></li> <li><a>服務聲明</a></li> <li><a>廣告聲明</a></li> </ul> </div> <div style="text-align: center;margin-top: 5px;margin-bottom:20px;"> Copyright © 2005-2016 傳智商城 版權全部 </div> </body> <script type="text/javascript"> function subForm(){ //讓指定的表單提交 document.getElementById("form1").submit(); } </script> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <!doctype html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>會員登陸</title> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css" type="text/css" /> <script src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js" type="text/javascript"></script> <script src="${pageContext.request.contextPath}/js/bootstrap.min.js" type="text/javascript"></script> <!-- 引入自定義css文件 style.css --> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" type="text/css" /> <style> body { margin-top: 20px; margin: 0 auto; width: 100%; } .carousel-inner .item img { width: 100%; height: 300px; } </style> </head> <body> <%@include file="/jsp/head.jsp" %> <div class="row" style="width:1210px;margin:0 auto;"> <div class="col-md-12"> <ol class="breadcrumb"> <li><a href="#">首頁</a></li> </ol> </div> <c:forEach items="${pb.data }" var="p"> <div class="col-md-2"> <a href="${pageContext.request.contextPath }/product?method=getById&pid=${p.pid}"> <img src="${pageContext.request.contextPath}/${p.pimage}" width="170" height="170" style="display: inline-block;"> </a> <p><a href="${pageContext.request.contextPath }/product?method=getById&pid=${p.pid}" style='color:green'>${fn:substring(p.pname,0,10) }..</a></p> <p><font color="#FF0000">商城價:¥${p.shop_price }</font></p> </div> </c:forEach> </div> <!--分頁 --> <div style="width:380px;margin:0 auto;margin-top:50px;"> <ul class="pagination" style="text-align:center; margin-top:10px;"> <!-- 判斷是不是第一頁 --> <c:if test="${pb.pageNumber == 1 }"> <li class="disabled"> <a href="javascript:void(0)" aria-label="Previous"> <span aria-hidden="true">«</span> </a> </li> </c:if> <!-- 不是第一頁 --> <c:if test="${pb.pageNumber != 1 }"> <li> <a href="${pageContext.request.contextPath }/product?method=findByPage&pageNumber=${pb.pageNumber-1}&cid=${param.cid}" aria-label="Previous"> <span aria-hidden="true">«</span> </a> </li> </c:if> <!-- 展現全部頁碼 --> <c:forEach begin="1" end="${pb.totalPage }" var = "n"> <!-- 判斷是不是當前頁 --> <c:if test="${pb.pageNumber == n }"> <li class="active"><a href="javascript:void(0)">${n }</a></li> </c:if> <c:if test="${pb.pageNumber != n }"> <li><a href="${pageContext.request.contextPath }/product?method=findByPage&cid=${param.cid}&pageNumber=${n}">${n }</a></li> </c:if> </c:forEach> <!-- 判斷是不是最後一頁 --> <c:if test="${pb.pageNumber == pb.totalPage }"> <li class="disabled"> <a href="javascript:void(0)" aria-label="Next"> <span aria-hidden="true">»</span> </a> </li> </c:if> <c:if test="${pb.pageNumber != pb.totalPage }"> <li> <a href="${pageContext.request.contextPath }/product?method=findByPage&cid=${param.cid}&pageNumber=${pb.pageNumber+1}" aria-label="Next"> <span aria-hidden="true">»</span> </a> </li> </c:if> </ul> </div> <!-- 分頁結束======================= --> <!-- 商品瀏覽記錄: --> <div style="width:1210px;margin:0 auto; padding: 0 9px;border: 1px solid #ddd;border-top: 2px solid #999;height: 246px;"> <h4 style="width: 50%;float: left;font: 14px/30px " 微軟雅黑 ";">瀏覽記錄</h4> <div style="width: 50%;float: right;text-align: right;"><a href="">more</a></div> <div style="clear: both;"></div> <div style="overflow: hidden;"> <ul style="list-style: none;"> <li style="width: 150px;height: 216;float: left;margin: 0 8px 0 0;padding: 0 18px 15px;text-align: center;"><img src="${pageContext.request.contextPath}/products/1/cs10001.jpg" width="130px" height="130px" /></li> </ul> </div> </div> <div style="margin-top:50px;"> <img src="${pageContext.request.contextPath}/image/footer.jpg" width="100%" height="78" alt="咱們的優點" title="咱們的優點" /> </div> <div style="text-align: center;margin-top: 5px;"> <ul class="list-inline"> <li><a>關於咱們</a></li> <li><a>聯繫咱們</a></li> <li><a>招賢納士</a></li> <li><a>法律聲明</a></li> <li><a>友情連接</a></li> <li><a target="_blank">支付方式</a></li> <li><a target="_blank">配送方式</a></li> <li><a>服務聲明</a></li> <li><a>廣告聲明</a></li> </ul> </div> <div style="text-align: center;margin-top: 5px;margin-bottom:20px;"> Copyright © 2005-2016 傳智商城 版權全部 </div> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!doctype html> <html> <head></head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>會員登陸</title> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css" type="text/css" /> <script src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js" type="text/javascript"></script> <script src="${pageContext.request.contextPath}/js/bootstrap.min.js" type="text/javascript"></script> <!-- 引入自定義css文件 style.css --> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" type="text/css"/> <style> body{ margin-top:20px; margin:0 auto; } .carousel-inner .item img{ width:100%; height:300px; } .container .row div{ /* position:relative; float:left; */ } font { color: #3164af; font-size: 18px; font-weight: normal; padding: 0 10px; } </style> </head> <body> <!-- 時間:2015-12-30 描述:菜單欄 --> <div class="container-fluid"> <div class="col-md-4"> <img src="${pageContext.request.contextPath}/img/logo2.png" /> </div> <div class="col-md-5"> <img src="${pageContext.request.contextPath}/img/header.png" /> </div> <div class="col-md-3" style="padding-top:20px"> <ol class="list-inline"> <li><a href="login.htm">登陸</a></li> <li><a href="register.htm">註冊</a></li> <li><a href="cart.htm">購物車</a></li> </ol> </div> </div> <!-- 時間:2015-12-30 描述:導航條 --> <div class="container-fluid"> <nav class="navbar navbar-inverse"> <div class="container-fluid"> <!-- Brand and toggle get grouped for better mobile display --> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">首頁</a> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li class="active"><a href="#">手機數碼<span class="sr-only">(current)</span></a></li> <li><a href="#">電腦辦公</a></li> <li><a href="#">電腦辦公</a></li> <li><a href="#">電腦辦公</a></li> </ul> <form class="navbar-form navbar-right" role="search"> <div class="form-group"> <input type="text" class="form-control" placeholder="Search"> </div> <button type="submit" class="btn btn-default">Submit</button> </form> </div> <!-- /.navbar-collapse --> </div> <!-- /.container-fluid --> </nav> </div> <div class="container" style="width:100%;background:url('${pageContext.request.contextPath}/image/regist_bg.jpg');"> <div class="row"> <div class="col-md-2"></div> <div class="col-md-8" style="background:#fff;padding:40px 80px;margin:30px;border:7px solid #ccc;"> <font>會員註冊</font>USER REGISTER <form class="form-horizontal" style="margin-top:5px;" method="post" action="${pageContext.request.contextPath }/user"> <input type="hidden" name="method" value="regist"> <div class="form-group"> <label for="username" class="col-sm-2 control-label">用戶名</label> <div class="col-sm-6"> <input type="text" class="form-control" id="username" placeholder="請輸入用戶名" name="username"> </div> </div> <div class="form-group"> <label for="inputPassword3" class="col-sm-2 control-label">密碼</label> <div class="col-sm-6"> <input type="password" class="form-control" id="inputPassword3" placeholder="請輸入密碼" name="password"> </div> </div> <div class="form-group"> <label for="confirmpwd" class="col-sm-2 control-label">確認密碼</label> <div class="col-sm-6"> <input type="password" class="form-control" id="confirmpwd" placeholder="請輸入確認密碼"> </div> </div> <div class="form-group"> <label for="inputEmail3" class="col-sm-2 control-label">Email</label> <div class="col-sm-6"> <input type="email" class="form-control" id="inputEmail3" placeholder="Email" name="email"> </div> </div> <div class="form-group"> <label for="usercaption" class="col-sm-2 control-label">姓名</label> <div class="col-sm-6"> <input type="text" class="form-control" id="usercaption" placeholder="請輸入姓名" name="name"> </div> </div> <div class="form-group opt"> <label for="inlineRadio1" class="col-sm-2 control-label">性別</label> <div class="col-sm-6"> <label class="radio-inline"> <input type="radio" name="sex" id="inlineRadio1" value="1"> 男 </label> <label class="radio-inline"> <input type="radio" name="sex" id="inlineRadio2" value="0"> 女 </label> </div> </div> <div class="form-group"> <label for="date" class="col-sm-2 control-label">出生日期</label> <div class="col-sm-6"> <input type="date" class="form-control" name="birthday"> </div> </div> <div class="form-group"> <label for="date" class="col-sm-2 control-label">驗證碼</label> <div class="col-sm-3"> <input type="text" class="form-control" > </div> <div class="col-sm-2"> <img src="${pageContext.request.contextPath}/image/captcha.jhtml"/> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <input type="submit" width="100" value="註冊" name="submit" border="0" style="background: url('${pageContext.request.contextPath}/images/register.gif') no-repeat scroll 0 0 rgba(0, 0, 0, 0); height:35px;width:100px;color:white;"> </div> </div> </form> </div> <div class="col-md-2"></div> </div> </div> <div style="margin-top:50px;"> <img src="${pageContext.request.contextPath}/image/footer.jpg" width="100%" height="78" alt="咱們的優點" title="咱們的優點" /> </div> <div style="text-align: center;margin-top: 5px;"> <ul class="list-inline"> <li><a>關於咱們</a></li> <li><a>聯繫咱們</a></li> <li><a>招賢納士</a></li> <li><a>法律聲明</a></li> <li><a>友情連接</a></li> <li><a target="_blank">支付方式</a></li> <li><a target="_blank">配送方式</a></li> <li><a>服務聲明</a></li> <li><a>廣告聲明</a></li> </ul> </div> <div style="text-align: center;margin-top: 5px;margin-bottom:20px;"> Copyright © 2005-2016 傳智商城 版權全部 </div> </body></html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <%-- <% //response.sendRedirect(request.getContextPath()+"/jsp/index.jsp"); request.getRequestDispatcher("/index").forward(request, response); %> --%> <jsp:forward page="/index"></jsp:forward> </body> </html>
完 ,奮戰六日終於完成,引用一句話,儘管不是最完美的,但能完成就是最好的。