分享一个易买网项目的实例教程

2025-10-26
网站建设限时活动促销

                             

0.开发流程:

1.项目约定:

   6个小组:

小组项目名称:EasyBuy_flc或者(EasyBuy_01)

小组数据库名称:EasyBuy_flc

版本控制工具:svn,不再使用

将来可以将自己小组的项目上传到git上

 

开发流程控制:     

组长:所有的html页面改成jsp后缀,并且,然后确立数据库和数据表

      A组员:设计数据库,书写数据表中文字段名称

      B组员:设计实体类

项目开发步骤

1.数据库设计

 

 

 easybuy_user(用户表)   表1

  EU_USER_ID varchar       用户名

  EU_USER_NAME varchar     真实姓名

  EU_PASSWORD varchar      密码

  EU_SEX varchar           性别(T,F)

  EU_BIRTHDAY date         出生日期

  EU_IDENTITY_CODE varchar 身份证

  EU_EMAIL varchar         电子邮件

============================================================

 

 easybuy_product_category (商品分类表)  表2

 

EPC_ID                分类编号

 

EPC_NAME              分类名称

 

EPC_PARENT_ID         父分类编号

=======================================

easybuy_product(商品表)  表3

   EP_ID           商品编号

   EP_NAME        商品名称

   EP_DESCRIPTION   商品描述

   EP_PRICE         商品价格

   EP_STOCK         商品库存

   EPC_ID           当前商品所属分类的父分类编号

   EPC_CHILD_ID     当前商品所属分类

   EP_FILE_NAME     商品图片名称

============================================================

 

easybuy_order(订单表) 表4

 

EO_ID            订单编号

 

EO_USER_ID       订单所属用户

 

EO_USER_NAME     订单所属用户(真实名称)

 

EO_USER_ADDRESS  订单送货地址

 

EO_CREATE_TIME   订单形成时间

 

EO_COST          本单金额

 

EO_STATUS        订单状态

 

EO_TYPE          订单类型 (本项目未启用)

=====================================================

 

easybuy_order_detail (订单详情表) 表5

 

   EOD_ID          订单详情编号

 

EO_ID           订单编号

 

EP_ID           商品编号

 

EOD_QUANTITY    商品数量

 

EOD_COST        单品金额

==========================================================

 

easybuy_news (新闻表)   表6

 

   EN_ID           新闻编号

 

   EN_TITLE        新闻标题

 

   EN_CONTENT      新闻内容

 

   EN_CREATE_TIME   新闻发布时间

===================================================

 

easybuy_comment (评论表)  表7

 

EC_ID            评论编号

 

EC_CONTENT       评论内容

 

EC_CREATE_TIME   评论创建时间

 

EC_REPLY          评论回复

 

EC_REPLY_TIME     评论回复时间

 

EC_NICK_NAME      评论人

==============================================================

 

2.项目架构的搭建

 

2.1从实体层开始  

Entity层代码如下:

 User用户类:

Product_category产品类:

Product商品信息表:

Order订单表:

Order_detail订单详情表:

News资讯表:

User_address地址类:

Count类:

开始着手项目:1:

我的登录:

功能是:效验,验证码,登录成功跳转页面。

开始分层:

工具BaseDao:

package cn.com.dao;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import javax.naming.Context;import javax.naming.InitialContext;import javax.sql.DataSource;public class BaseDAO {public static final String driver = "com.mysql.jdbc.Driver";public static final String url = "jdbc:mysql://localhost:3306/easybuy?useUnicode=true&charaterEncoding=UTF-8";public static final String username = "root";public static final String pwd = "1234";public Connection con=null;public PreparedStatement ps=null;public ResultSet rs=null;    //获取连接getConnectionpublic Connection getConnection() throws Exception {//加载驱动        Class.forName(driver);if (con == null || con.isClosed()) {            con = DriverManager.getConnection(url, username, pwd);        }return con;    }//查询 executeQuerypublic ResultSet executeQuery(String sql, Object...objects) throws Exception {        con = getConnection();        ps = con.prepareStatement(sql);for (int i = 0; i 

dao层:

   select(String name,String pwd)  Exception;}

dao的实现层:

  UserDaoImpl  BaseDAO   select(String name,String pwd) ="select count(1) from easybuy_user where loginname=? and loginname=?"=(rs!==rs.getInt("id"

services层:

   select(String name,String pwd)

services实现层:

public class UserServiceImpl implements IUserService{UserDaoImpl dao=new UserDaoImpl();@Overridepublic int select(String name, String pwd) throws Exception {return dao.select(name, pwd);}@Override public List getAllList() throws Exception { return dao.getAllList(); }}

静态页面:

 
valign="top">
登录 还没有商城账号,立即注册
用户名
密 码
验证码 分享一个易买网项目的实例教程看不清 <script>$("#msg").html("");<script>$("#msg").html("验证码不一致");

MD5加密工具:

public class Md5Tool{ public String getMD5(String pwd){ //用于加密的字符 char md5String[] ={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; try{//使用平台的默认字符集将此String编码为bytex序列,并将结果存储到一个新的byte数组中 byte[] btInput=pwd.getBytes(); //信息摘要是安全的单向哈希函数,它接受任意大小的数据,并输出固定长度的哈希值。 MessageDigest mdInst=MessageDigest.getInstance("MD5"); //MessageDisgest对象通过使用update方法处理数据,使用指定的byte数组更新摘要 mdInst.update(btInput); //摘要更新之后,通过调用disgest()执行哈希计算,获得密文 byte[] md = mdInst.digest();//把密文转换成十六进制的字符串形式 int j=md.length; char str[] = new char[j*2]; int k=0; for(int i=0;i>>4&0xf]; //5 str[k++] = md5String[byte0&0xf]; //F } //返回经过加密后的字符串return new String(str); }catch(Exception e) return null;}}}

验证码问题:

1.为什么要在网站中加入验证码?

解析:为了防止机器恶意注册,1s内在我们的数据库中形成N条记录

2.验证码实现机制:

解析:为了防止浏览器读取缓存中的验证码图片,首先在形成验证码的Servlet处理程序中设置浏览器不缓存,第二种手段就是给请求的Servlet加一个随机数,这样就保证每次都从服务器拿一张验证码图片。说白了验证码就是一个服务器端的后台类(Servlet),以流的方式回送到客户端浏览器,用img标签承载。

3.雕虫小技

解析:验证的时候先进行验证码的校验,如果发现验证码不匹配, 就不用再验证用户名和密码,这样就省去了和数据库的一次交互。

验证码工具书写:

package cn.buy.util;import java.awt.Color;import java.awt.Font;import java.awt.Graphics;import java.awt.image.BufferedImage;import java.util.Random;public class AuthCode {public static final int AUTHCODE_LENGTH = 5; //验证码长度 public static final int SINGLECODE_WIDTH = 15; //单个验证码宽度 public static final int SINGLECODE_HEIGHT = 30; //单个验证码高度 public static final int SINGLECODE_GAP = 4; //单个验证码之间间隔 public static final int IMG_WIDTH = AUTHCODE_LENGTH * (SINGLECODE_WIDTH + SINGLECODE_GAP); public static final int IMG_HEIGHT = SINGLECODE_HEIGHT; public static String getAuthCode() { String authCode = ""; for(int i = 0; i < AUTHCODE_LENGTH; i++) { authCode += (new Random()).nextInt(10); } return authCode; } public static BufferedImage getAuthImg(String authCode) { //设置图片的高、宽、类型 //RGB编码:red、green、blue BufferedImage img = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, BufferedImage.TYPE_INT_BGR); //得到图片上的一个画笔 Graphics g = img.getGraphics(); //设置画笔的颜色,用来做背景色 g.setColor(Color.YELLOW); //用画笔来填充一个矩形,矩形的左上角坐标,宽,高 g.fillRect(0, 0, IMG_WIDTH, IMG_HEIGHT); //将画笔颜色设置为黑色,用来写字 g.setColor(Color.BLACK); //设置字体:宋体、不带格式的、字号 g.setFont(new Font("宋体", Font.PLAIN, SINGLECODE_HEIGHT + 5)); //输出数字 char c; for(int i = 0; i < authCode.toCharArray().length; i++) { //取到对应位置的字符 c = authCode.charAt(i); //画出一个字符串:要画的内容,开始的位置,高度 g.drawString(c + "", i * (SINGLECODE_WIDTH + SINGLECODE_GAP)+ SINGLECODE_GAP / 2, IMG_HEIGHT); } Random random = new Random(); //干扰素 for(int i = 0; i < 20; i++) { int x = random.nextInt(IMG_WIDTH); int y = random.nextInt(IMG_HEIGHT); int x2 = random.nextInt(IMG_WIDTH); int y2 = random.nextInt(IMG_HEIGHT); g.drawLine(x, y, x + x2, y + y2); } return img; } }

验证码的servlet书写:

public class AuthCodeServlet extends Httpservlet {public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException { doPost(request, response); }public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException { String authCode = AuthCode.getAuthCode(); request.getSession().setAttribute("authCode", authCode); //将验证码保存到session中,便于以后验证 try { //发送图片 ImageIO.write(AuthCode.getAuthImg(authCode), "JPEG", response.getOutputStream()); } catch (IOException e){ e.printStackTrace(); } }}

验证码的Ajax,,登录的效验,,鼠标悬停和离开:

前台页面显示js:

1.光标的显示和离开

2.验证码的显示

<script type="text/javascript">$(function() { $("#myid").click(function() { $.ajax({ url : "/EasyBuy/AuthCodeServlet", type : "get", success : function(dom) { document.getElementById("authImg").src = "AuthCodeServlet"; } }); }); }); $(function(){ var erro=0; $(".l_user").focus(function() { $("#lid").html("请输入用户名"); }); $(".l_user").blur(function(){if($(this).val()==""){ $("#lid").html(""); }else if ($(this).val() != "" && /^[a-zA-Z]{1}([a-zA-Z]|[0-9]){4,15}$/.test($(this).val())) { $("#lid").html(""); } else { $("#lid").html("请输入正确的用户名(首字母为英文,5-15位)"); } }); $(".l_pwd").focus(function(){ $("#pid").html("请输入密码"); }); $(".l_pwd").blur(function(){if($(this).val()==""){ erro=1; $("#pid").html(""); }else if ($(this).val() != "" && /^.{1,16}$/.test($(this).val())) { erro=0; $("#pid").html(""); } else { $("#pid").html("密码格式不正确"); erro=1; } }); }); function checks(myform) {if (myform.luser.value == "") { $("#lid").html("请输入用户名");return false; }else if (myform.lpwd.value =="") { $("#pid").html("请输入密码");return false; }return true; }

根据前台页面表单里action的跳转:servelet:

Md5Tool md5Tool=new Md5Tool();IUserService service = new UserServiceImpl();if("login".equals(resquest.getParameter("title")){ String name=request.getParameter("luser"); String pwds=request.getParameter("lpwd");if(name==null&&pwds==null){ response.sendRedirect("/EasyBuy/Login.jsp");}else{ name=new String(name.getBytes("iso-8859-1"),"utf-8"); pwds=new String(pwds.getBytes("iso-8859-1"),"utf-8"); String mm=(String)request.getSession().getAttribute("authCode"); String yy=request.getParameter("yzm"); //获取验证码if(!yy.equest(mm)){ request.getSession().setAttribute("mm","flag"); response.sendRedirect("/EasyBuy/Login.jsp"); }else{try{ request.getSession().setAttribute("user",service.getAllList(name)); pwds=md5Tool.getMD5(pwds); int num=service.select(name,pwds); if(num>0){ request.setAttribute("uname".service.getAllList(name).getUserName()); request.getRequestDispatcher("/Index.jsp").forward(request,response); }else{ response.sendRedirect("/EasyBuy/Login.jsp"); } }catch(Exception e){ e.printStackTrace(); } } } }}

2.注册:

效果图:

输入正确后即可显示登陆

在dao层:

public interface IUserDao {//插入用户信息传递一个用户对象public int add(User users) throws Exception;}

dao实现层:

public class UserDaoImpl extends BaseDAO implements IUserDao{ @Overridepublic int add(User users) throws Exception { String sql="insert into easybuy_user values(null,?,?,?,?,?,?,?,0)"; Object[] obj={users.getLoginName(),users.getUserName(),users.getPassword(),users.getSex(),users.getIdentityCode(),users.getEmail(),users.getMobile()};int num = executeUpdate(sql, obj);return num; }}

services层:

 add(User users) throws Exception;}

services实现层:

public class UserServiceImpl implements IUserService{ UserDaoImpl dao=new UserDaoImpl(); @Overridepublic int add(User users) throws Exception { return dao.add(users); }}

在我的servlet层:

 Md5Tool md5Tool = (.equals(request.getParameter(= = =  items = iter == == (filename.equals(.println(fileItem.getString( (filename.equals(.println(fileItem.getString( (filename.equals(.println(fileItem.getString( (filename.equals(= fileItem.getString( (sex.equals( (sex.equals( (filename.equals( (filename.equals( (filename.equals( (filename.equals(== fileItem.getString( (!= num = (num >

我的前台页面:

注册 已有商城账号,我要登录
* 登录用户名
* 密码
* 确认密码
* 真实姓名
* 性别
* 身份证号
* 邮箱
* 手机
* 验证码 分享一个易买网项目的实例教程看不清 <script> $("#msg").html(""); <script> $("#msg").html("验证码不一致");

jq的实现:

<script> $(function(){ $("#myid").click(function(){ $.ajax({ url:"/EasyBuy/AuthCodeServlet", type:"get", success:function(){ document.getElementById("authImg").src ="AuthCodeServlet"; } }); }); $(".l_user").blur(function(){ $.ajax({ type:"get", url:"<%=path%>/LoginServlet?login="+$(".l_user").val(), success:function(dom){if(dom){ $("#uid").html("用户名已被注册,请重新命名"); } } }); }); }); 

3.我的新闻资讯:

页面显示:

点更多的时候:

在我的dao层:

public interface INewsDAO{ //查询资讯//资讯的分页 public List newsList(int pageSize, int PageIndex) throws Exception;//咨询的数量,配合分页一起 public int newscount() throws Exception;//根据我的id查资讯 public List newsList(String id) throws Exception;}

在我的dao层的查数据:

public class NewsDAOImpl extends BaseDAO implements INewsDAO{ @Override public List newsList(String id) throws Exception{//新闻放到集合里List list = new ArrayList();//把sql语句放到结果集里ResultSet rs=executeQuery("select * from easybuy_news where id=? LIMIT 0,1",id);//调用我的工具类Tool tool = new Tool();//将我的rs对象转成集合了list.add(tool.list(rs,News.class).get(0));//查询我的分页数据,上一页,下一页。rs=executeQuery("select * from (select * from easybuy_news order by id desc) a where id? LIMIT 0,1",id);if(rs.next()){ rs=executeQuery("select * from easybuy_news where id>? LIMIT 0,1",id); list.add(tool.list(rs,News.class).get(0));} close();return list;} @Overridepublic List newsList(int pageSize, int PageIndex) throws Exception{ ResultSet rs=executeQuery(“select * from easybuy_news order by id desc LIMIT ?,?”,(PageIndex-1)*pageSize,pageSize); Tool tool = new Tool(); List list = tool.list(rs,News.class); close();return list;}@Overridepublic int newscount() throws Exception{ int count=0; ResultSet rs=executeQuery("select count(1) from easybuy_news"); if(rs.next()){ count=rs.getInt(1);} return count;}}

Tool工具类:

public class Tool { @SuppressWarnings("unchecked")public List list(ResultSet rs,Class cls) throws Exception{ List list=new ArrayList(); Field[] fields = cls.getDeclaredFields();if(rs!=null){while (rs.next()) { Object obj=cls.newInstance();for (Field field : fields) { String name=field.getName(); Method method = cls.getDeclaredMethod("set"+name.substring(0,1).toUpperCase()+name.substring(1),field.getType());try { method.invoke(obj,rs.getObject(name)); } catch (Exception e) {continue; } } list.add((T)obj); } }return list; }}

在我的services层:

public interface INewsService {//查询资讯public List newsList(int pageSize, int PageIndex) throws Exception;public int newscount() throws Exception;public List newsList(String id) throws Exception;}

services实现层:

public class NewsServiceImpl implements INewsService{ INewsDAO dao=new NewsDAOImpl(); @Overridepublic List newsList(int pageSize, int PageIndex) throws Exception { return dao.newsList(pageSize,PageIndex); } @Overridepublic List newsList(String id) throws Exception {return dao.newsList(id); } @Overridepublic int newscount() throws Exception {return dao.newscount(); }}

我的servlet层:

public class NewsServlet extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); }public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { INewsService Service=new NewsServiceImpl(); String type=request.getParameter("type"); String id=request.getParameter("id"); String pageindex=request.getParameter("pageindex"); Page page=new Page();try {if("top5news".equals(type)){ request.setAttribute("News",Service.newsList(id)); }else if("newstable".equals(type)||(pageindex!=null&&!"".equals(pageindex))){if(pageindex!=null&&!"".equals(pageindex)){ page.setPageIndex(Integer.parseInt(pageindex)); } page.setPageCount(Service.newscount()); page.setPageList(Service.newsList(page.getPageSize(), page.getPageIndex())); request.setAttribute("page",page); } request.getRequestDispatcher("MyJsp.jsp").forward(request, response); } catch (Exception e) { e.printStackTrace(); } }}

在我的前台页面:

index.jsp

更多 新闻资讯

集合NewsList在三级分类里:

//资讯集合request.setAttribute("clist", list); request.setAttribute("NewsList",newsService.newsList(5,1)); request.getRequestDispatcher(url).forward(request, response);

index.jsp:

  <%@ include file="children/title.jsp" %>

title.jsp:

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><%@ taglib uri="" prefix="c" %><%@ taglib prefix="fn" uri=""%> 

加入收藏

请选择所在的收货地区

A 安徽澳门
B 北京
C 重庆
F 福建
G 广东广西贵州甘肃
H 河北河南黑龙江海南湖北湖南
J 江苏吉林江西
L 辽宁
N 内蒙古宁夏
Q 青海
S 上海山东山西四川陕西
T 台湾天津
X 西藏香港新疆
Y 云南
Z 浙江

你好,欢迎您:${user.userName } | 我的订单 |注销 你好,请登录 免费注册

收藏夹

    暂无收藏商品!

客户服务

网站导航

| 关注我们: 新浪微信 | 手机版 分享一个易买网项目的实例教程

咖啡 iphone 6S 新鲜美食 蛋糕 日用品 连衣裙

购物车 [ ${pcount} ]

购物车 [ 0 ]

共计 ${pprice }

去购物车结算

<script type="text/javascript">function deleteCartGoods(rec_id){Ajax.call('delete_cart_goods.php', 'id='+rec_id, deleteCartGoodsResponse, 'POST', 'JSON');}function deleteCartGoodsResponse(res){ if (res.error) { alert(res.err_msg); } else { document.getElementById('ECS_CARTINFO').innerHTML = res.content; }}

中秋送好礼!

在我的sevlet:

package cn.buy.servlet;import java.io.IOException;import java.io.PrintWriter;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;import javax.servlet.ServletException;import javax.servlet.http.Cookie;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import cn.buy.entity.Product;import cn.buy.entity.Product_category;import cn.buy.service.INewsService;import cn.buy.service.IProductService;import cn.buy.service.IProduct_categoryService;import cn.buy.service.impl.NewsServiceImpl;import cn.buy.service.impl.ProductServiceImpl;import cn.buy.service.impl.Product_categoryServiceImpl;public class Product_categoryServlet extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//三级列表IProduct_categoryService service = new Product_categoryServiceImpl();//资讯INewsService newsService=new NewsServiceImpl();//获取请求页面urlString url=(String)request.getAttribute("url"); Map>> map = new HashMap>>();try {for (Product_category oneitem : service.oneList()) { Map> twomap=new HashMap>();for (Product_category twoitem : service.twoList(oneitem.getId())) { List list=new ArrayList();for (Product_category threeitem : service.threeList(twoitem.getId())){ list.add(threeitem); } twomap.put(twoitem, list); } map.put(oneitem, twomap); }//三级列表集合request.setAttribute("map",map); IProductService service1 = new ProductServiceImpl(); List list = new ArrayList(); Cookie[] cookies = request.getCookies();int j = 0;for (int i = cookies.length-1; i >= 1; i--) {if (cookies[i].getValue().equals("id")) { j++;if (j <= 5) {try { list.add(service1.List(cookies[i].getName())); } catch (Exception e) { e.printStackTrace(); } } } }//资讯集合request.setAttribute("clist", list); request.setAttribute("NewsList",newsService.newsList(5,1)); request.getRequestDispatcher(url).forward(request, response); } catch (Exception e) { e.printStackTrace(); } }}

我的三级菜单:

package cn.buy.servlet;import java.io.IOException;import java.io.PrintWriter;import java.util.ArrayList;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import javax.servlet.ServletException;import javax.servlet.http.Cookie;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.swing.RepaintManager;import net.sf.json.JSONArray;import net.sf.json.JSONObject;import cn.buy.entity.Count;import cn.buy.entity.News;import cn.buy.entity.Product;import cn.buy.service.IProductService;import cn.buy.service.impl.ProductServiceImpl;import cn.buy.util.Page;public class ProductServlet extends HttpServlet { String name=null;public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {if(name==null&&request.getParameter("keywords")!=null){ name = new String(request.getParameter("keywords").getBytes("ISO-8859-1"),"utf-8"); } doPost(request, response); }public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); IProductService service = new ProductServiceImpl(); String id=request.getParameter("id"); String type=request.getParameter("type"); String oneid = request.getParameter("oneid"); String twoid = request.getParameter("twoid"); String threeid = request.getParameter("threeid"); String pcount = request.getParameter("pcount"); String pageindex=request.getParameter("pageindex"); Page page=new Page();if(name==null){ name = request.getParameter("keywords"); }if ("fl".equals(type)) {try { page.setPageSize(4);if(pageindex!=null&&!"".equals(pageindex)){ page.setPageIndex(Integer.parseInt(pageindex)); }if (oneid != null && !"".equals(oneid)) { page.setPageCount(service.pcount(oneid, "one")); page.setPageList(service.List(page.getPageSize(), page.getPageIndex(),oneid,"one")); request.setAttribute("count",service.pcount(oneid, "one")); request.setAttribute("oneid", oneid); } else if (twoid != null && !"".equals(twoid)) { page.setPageCount(service.pcount(twoid, "two")); page.setPageList(service.List(page.getPageSize(), page.getPageIndex(),twoid,"two")); request.setAttribute("count",service.pcount(twoid, "two")); request.setAttribute("twoid", twoid); } else if (threeid != null && !"".equals(threeid)) { page.setPageCount(service.pcount(threeid, "three")); page.setPageList(service.List(page.getPageSize(), page.getPageIndex(),threeid,"three")); request.setAttribute("count",service.pcount(threeid, "three")); request.setAttribute("threeid", threeid); }else if (name != null) { page.setPageCount(service.pcount(name, "ss")); page.setPageList(service.List(page.getPageSize(), page.getPageIndex(),name,"ss")); request.setAttribute("count",service.pcount(name, "ss")); request.setAttribute("ss",name); name=null; } } catch (Exception e) { e.printStackTrace(); } request.setAttribute("page",page); request.getRequestDispatcher("BrandListjsp").forward(request, response); }else if("gwc".equals(type)){ List plist=(List)request.getSession().getAttribute("plist");if(plist==null){ plist=new ArrayList(); }int count=0;double price=0; boolean flag=true;try {if(pcount==null||"".equals(pcount)){ pcount="1"; }for (Product item : plist) {if(item.getId()==Integer.parseInt(id) ){ item.setCount(item.getCount()+Integer.parseInt(pcount)); flag=false;break; } } if(flag&&pcount!=null&&!"".equals(pcount)){ Product product=service.List(id); product.setCount(Integer.parseInt(pcount)); plist.add(product); } for (Product item : plist) { count+=item.getCount(); price+=item.getCount()*item.getPrice(); }for (Product item : plist) { item.setCount1(count); item.setPrice1(price); } JSONArray jsonArray=JSONArray.fromObject( plist); request.getSession().setAttribute("plist",plist); request.getSession().setAttribute("pprice",price); request.getSession().setAttribute("pcount",count); response.getWriter().print(jsonArray); } catch (Exception e) { e.printStackTrace(); } }else if("jia".equals(type)||"jian".equals(type)){int count=0;double price=0; List plist=(List)request.getSession().getAttribute("plist");for (Product item : plist) {if(item.getId()==Integer.parseInt(id) ){if("jia".equals(type)){ item.setCount(item.getCount()+1); }else{ item.setCount(item.getCount()-1); }break; } }for (Product item : plist) { count+=item.getCount(); price+=item.getCount()*item.getPrice(); }for (Product item : plist) { item.setCount1(count); item.setPrice1(price); } JSONArray jsonArray=JSONArray.fromObject( plist); response.getWriter().print(jsonArray); request.getSession().setAttribute("plist",plist); request.getSession().setAttribute("pprice",price); request.getSession().setAttribute("pcount",count); }else if("de".equals(type)){ response.getWriter().print(id); }else if("delete".equals(type)||"qk".equals(type)){int count=0;double price=0; List plist=(List)request.getSession().getAttribute("plist");if("delete".equals(type)){for (int i=0;i

单点的一个跳转:分页中的下一篇和上一篇

[特惠]${News[0].title }

${News[0].brief }/${News[0].createTime }

${News[0].content}

下一篇:${News[1].title }
上一篇:${News[2].title }

商品分类:

前台:

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><%@ taglib uri="" prefix="c"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>lns="">  <script type="text/javascript" src="js/jquery-1.11.1.min_044d0927.js"> <script type="text/javascript" src="js/jquery-1.8.2.min.js"> <script type="text/javascript" src="js/menu.js"> <script type="text/javascript" src="js/lrscroll_1.js"> <script type="text/javascript" src="js/n_nav.js">   <script type="text/javascript" src="js/MagicZoom.js"> <script type="text/javascript" src="js/num.js">var jq = jQuery.noConflict(); <script type="text/javascript" src="js/p_tab.js"> <script type="text/javascript" src="js/shade.js"> <script>$(function(){ $(".mya").click(function(){  location.href="Login.jsp?tz=1"; $.ajax({ url:"/EasyBuy/ProductServlet?id="+$product.id+"&type=gwc&pcount="+$("#myinput").val(), type:"get", dataType: "json", success:function(data){var li="";var count=0;var count1=0;var price1=0; $.each(data,function(i,item){ count++; if(i==0){ $("#p").html("

共计 ${pprice }

去购物车结算

"); $("#gw").text(item.count1); $("#zj").text(item.price1); count1=item.count1; price1=item.price1; } li+="
  • "+item.name+"

    "+item.price+" X"+item.count+"

  • "; }); $("#gwc").html("购物车共有"+count+"种宝贝("+count1+"件) 合计:"+price1+"元"); $("#ul").html(li); ShowDiv('MyDiv1','fade1'); } }); }); }); <%@ include file="children/title.jsp" %>

    分享一个易买网项目的实例教程

    Loading...

    ${product.name }

    “开业巨惠,北京专柜直供”,不光低价,“真”才靠谱!

    本店价格:${product.price }
    消费积分:28R

    型号选择:

    • 30ml

    • 50ml

    • 100ml

    颜色选择:

    • 红色

    • 白色

    • 黑色

    分享

    分享一个易买网项目的实例教程 分享一个易买网项目的实例教程 分享一个易买网项目的实例教程 分享一个易买网项目的实例教程 分享一个易买网项目的实例教程

    关注商品

    分享一个易买网项目的实例教程

    分享一个易买网项目的实例教程

    进入品牌专区

    <%@ include file="children/left.jsp" %>

    • 推荐搭配

    分享一个易买网项目的实例教程

    倩碧补水组合套装8折促销

    768.00 18R

    分享一个易买网项目的实例教程

    分享一个易买网项目的实例教程

    香奈儿邂逅清新淡香水50ml

    749.00 18R

    分享一个易买网项目的实例教程

    分享一个易买网项目的实例教程

    香奈儿邂逅清新淡香水50ml

    749.00 18R

    分享一个易买网项目的实例教程

    套餐价:¥1517

    分享一个易买网项目的实例教程

    商品名称:迪奥香水 商品编号:1546211 品牌: 迪奥(Dior) 上架时间:2015-09-06 09:19:09
    商品毛重:160.00g 商品产地:法国 香调:果香调香型:淡香水/香露EDT
    容量:1ml-15ml 类型:女士香水,Q版香水,组合套装

    商品详情

    分享一个易买网项目的实例教程 迪奥真我香水(Q版)
    【商品规格】:5ml
    【商品质地】:液体
    【商品日期】:与专柜同步更新
    【商品产地】:法国
    【商品包装】:无外盒 无塑封
    【商品香调】:花束花香调
    【适用人群】:适合女性(都市白领,性感,有女人味的成熟女性)

    分享一个易买网项目的实例教程

    分享一个易买网项目的实例教程

    分享一个易买网项目的实例教程

    分享一个易买网项目的实例教程

    商品评论

    80.0%

    好评度
    好评(80%) 分享一个易买网项目的实例教程
    中评(20%) 分享一个易买网项目的实例教程
    差评(0%) 分享一个易买网项目的实例教程
    购买过雅诗兰黛第六代特润精华露50ml的顾客,在收到商品才可以对该商品发表评论 您可对已购买商品进行评价
    分享一个易买网项目的实例教程
    分享一个易买网项目的实例教程 向死而生 颜色分类:粉色
    型号:50ml
    产品很好,香味很喜欢,必须给赞。
    2015-09-24
    分享一个易买网项目的实例教程 就是这么想的 颜色分类:粉色
    型号:50ml
    送朋友,她很喜欢,大爱。
    2015-09-24
    分享一个易买网项目的实例教程 墨镜墨镜 颜色分类:粉色
    型号:50ml
    大家都说不错
    2015-09-24
    分享一个易买网项目的实例教程 那*****洋
    (匿名用户)
    颜色分类:粉色
    型号:50ml
    下次还会来买,推荐。
    2015-09-24

    上一页123...20下一页

    分享一个易买网项目的实例教程

    分享一个易买网项目的实例教程 您已成功收藏该商品
    查看我的关注 >>
    确定

    分享一个易买网项目的实例教程

    分享一个易买网项目的实例教程 宝贝已成功添加到购物车
    购物车共有1种宝贝(3件) 合计:1120元
    去购物车结算继续购物

    分享一个易买网项目的实例教程

    正品保障

    正品行货 放心购买
    分享一个易买网项目的实例教程

    满38包邮

    满38包邮 免运费
    分享一个易买网项目的实例教程

    天天低价

    天天低价 畅选无忧
    分享一个易买网项目的实例教程

    准时送达

    收货时间由你做主

    新手上路
    售后流程
    购物流程
    订购方式
    隐私声明
    推荐分享说明
    配送与支付
    货到付款区域
    配送支付查询
    支付方式说明
    会员中心
    资金管理
    我的收藏
    我的订单
    服务保证
    退换货原则
    售后服务保证
    产品质量保证
    联系我们
    网站故障报告
    购物咨询
    投诉与建议

    新浪微博 腾讯微博

    服务热线:
    400-123-4567

    分享一个易买网项目的实例教程

    分享一个易买网项目的实例教程

    备案/许可证编号:蜀ICP备12009302号-1-www.dingguagua.com Copyright © 2015-2018 尤洪商城网 All Rights Reserved. 复制必究 , Technical Support: Dgg Group
    分享一个易买网项目的实例教程分享一个易买网项目的实例教程分享一个易买网项目的实例教程分享一个易买网项目的实例教程分享一个易买网项目的实例教程分享一个易买网项目的实例教程

    <script src="js/ShopShow.js">

    我的订单:

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> 

    管理中心

    订单中心

    会员中心

    账户中心

    我的订单OrderServlet类:

    package cn.buy.servlet;import java.io.IOException;import java.io.PrintWriter;import java.text.DateFormat;import java.text.SimpleDateFormat;import java.util.Date;import java.util.List;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import cn.buy.entity.Count;import cn.buy.entity.Order;import cn.buy.entity.Product;import cn.buy.entity.User;import cn.buy.service.IOrderSerice;import cn.buy.service.IRessService;import cn.buy.service.impl.OrderServiceImpl;import cn.buy.service.impl.RessServiceImpl;import cn.buy.util.Md5Tool;public class OrderServlet extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); }public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { User user= ((User)request.getSession().getAttribute("user")); IRessService ress=new RessServiceImpl(); IOrderSerice serice=new OrderServiceImpl(); String type=request.getParameter("type");if("cx".equals(type)){try { request.setAttribute("list",serice.orders(user.getId()+"")); request.getRequestDispatcher("/Member_Order.jsp").forward(request, response); } catch (Exception e) { e.printStackTrace(); } }else{ Md5Tool md5Tool=new Md5Tool(); List list=(List)request.getSession().getAttribute("plist"); double pprice=(Double)request.getSession().getAttribute("pprice"); Order order=new Order(); order.setCost(pprice); order.setLoginName(user.getLoginName()); order.setUserId(user.getId()); Date date=new Date(); DateFormat format=new SimpleDateFormat("yyyyMMddHHmmss"); String time=format.format(date); order.setSerialNumber( md5Tool.getMD5(time+user.getId())); try { order.setUserAddress(ress.Ress(user.getId()+"").getAddress());int id=serice.addorder(order);for (Product item : list) { serice.adddetail(id+"",item.getId()+"",item.getCount(), item.getCount()*item.getPrice()); } request.getSession().setAttribute("pprice",null); request.getSession().setAttribute("pcount",null); request.getSession().setAttribute("plist",null); request.setAttribute("ddbh", md5Tool.getMD5(time+user.getId())); request.setAttribute("price",pprice); request.getRequestDispatcher("BuyCar_Three.jsp").forward(request, response); }catch (Exception e) { e.printStackTrace(); } } }}

    订单的主要代码:

    package cn.buy.dao.impl;import java.nio.channels.SelectableChannel;import java.sql.ResultSet;import java.text.DateFormat;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Date;import java.util.List;import cn.buy.dao.BaseDAO;import cn.buy.dao.IOrderDAO;import cn.buy.entity.Order;import cn.buy.util.Tool;public class OrderDAOImpl extends BaseDAO implements IOrderDAO{ @Overridepublic int addorder(Order order) throws Exception { Date date=new Date(); DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String time=format.format(date);int count=executeUpdate("insert into easybuy_order values(?,?,?,?,?,?,?)",null,order.getUserId(),order.getLoginName(),order.getUserAddress(),time,order.getCost(),order.getSerialNumber());if(count>0){ ResultSet rs=executeQuery("select id FROM easybuy_order ORDER BY id DESC LIMIT 1 ");if(rs.next()){ count=rs.getInt(1); } } close();return count; } @Overridepublic boolean adddetail(String oid, String pid, int quantity, double cost) throws Exception {int count=executeUpdate("insert into easybuy_order_detail values (?,?,?,?,?)",null,oid,pid,quantity,cost); close();return count>0? true : false; } @Overridepublic List orders(String userid) throws Exception { ResultSet rs=executeQuery("select * from easybuy_order where userid=?", userid); List list=new ArrayList();if(rs!=null){while(rs.next()){ Order order=new Order(); order.setCost(rs.getDouble("Cost")); order.setCreateTime(rs.getString("CreateTime")); order.setId(rs.getInt("Id")); order.setLoginName(rs.getString("LoginName")); order.setSerialNumber(rs.getString("SerialNumber")); order.setUserAddress(rs.getString("UserAddress")); order.setUserId(rs.getInt("UserId")); list.add(order); } } close();return list; }}

    商品详情:

    我的另一个:

    我的商品详情的前台页面:

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><%@ taglib uri="" prefix="c"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>  <script type="text/javascript" src="js/jquery-1.11.1.min_044d0927.js"> <script type="text/javascript" src="js/jquery-1.8.2.min.js"> <script type="text/javascript" src="js/menu.js"> <script type="text/javascript" src="js/lrscroll_1.js"> <script type="text/javascript" src="js/n_nav.js">   <script type="text/javascript" src="js/MagicZoom.js"> <script type="text/javascript" src="js/num.js">var jq = jQuery.noConflict(); <script type="text/javascript" src="js/p_tab.js"> <script type="text/javascript" src="js/shade.js"> <script>$(function(){ $(".mya").click(function(){  location.href="Login.jsp?tz=1"; $.ajax({ url:"/EasyBuy/ProductServlet?id="+$product.id+"&type=gwc&pcount="+$("#myinput").val(), type:"get", dataType: "json", success:function(data){var li="";var count=0;var count1=0;var price1=0; $.each(data,function(i,item){ count++; if(i==0){ $("#p").html("

    共计 ${pprice }

    去购物车结算

    "); $("#gw").text(item.count1); $("#zj").text(item.price1); count1=item.count1; price1=item.price1; } li+="
  • "+item.name+"

    "+item.price+" X"+item.count+"

  • "; }); $("#gwc").html("购物车共有"+count+"种宝贝("+count1+"件) 合计:"+price1+"元"); $("#ul").html(li); ShowDiv('MyDiv1','fade1'); } }); }); }); <%@ include file="children/title.jsp" %>

    分享一个易买网项目的实例教程

    Loading...

    ${product.name }

    “开业巨惠,北京专柜直供”,不光低价,“真”才靠谱!

    本店价格:${product.price }
    消费积分:28R

    型号选择:

    • 30ml

    • 50ml

    • 100ml

    颜色选择:

    • 红色

    • 白色

    • 黑色

    分享

    分享一个易买网项目的实例教程 分享一个易买网项目的实例教程 分享一个易买网项目的实例教程 分享一个易买网项目的实例教程 分享一个易买网项目的实例教程

    关注商品

    分享一个易买网项目的实例教程

    分享一个易买网项目的实例教程

    进入品牌专区

    <%@ include file="children/left.jsp" %>

    • 推荐搭配

    分享一个易买网项目的实例教程

    倩碧补水组合套装8折促销

    768.00 18R

    分享一个易买网项目的实例教程

    分享一个易买网项目的实例教程

    香奈儿邂逅清新淡香水50ml

    749.00 18R

    分享一个易买网项目的实例教程

    分享一个易买网项目的实例教程

    香奈儿邂逅清新淡香水50ml

    749.00 18R

    分享一个易买网项目的实例教程

    套餐价:¥1517

    分享一个易买网项目的实例教程

    商品名称:迪奥香水 商品编号:1546211 品牌: 迪奥(Dior) 上架时间:2015-09-06 09:19:09
    商品毛重:160.00g 商品产地:法国 香调:果香调香型:淡香水/香露EDT
    容量:1ml-15ml 类型:女士香水,Q版香水,组合套装

    商品详情

    分享一个易买网项目的实例教程 迪奥真我香水(Q版)
    【商品规格】:5ml
    【商品质地】:液体
    【商品日期】:与专柜同步更新
    【商品产地】:法国
    【商品包装】:无外盒 无塑封
    【商品香调】:花束花香调
    【适用人群】:适合女性(都市白领,性感,有女人味的成熟女性)

    分享一个易买网项目的实例教程

    分享一个易买网项目的实例教程

    分享一个易买网项目的实例教程

    分享一个易买网项目的实例教程

    商品评论

    80.0%

    好评度
    好评(80%) 分享一个易买网项目的实例教程
    中评(20%) 分享一个易买网项目的实例教程
    差评(0%) 分享一个易买网项目的实例教程
    购买过雅诗兰黛第六代特润精华露50ml的顾客,在收到商品才可以对该商品发表评论 您可对已购买商品进行评价
    分享一个易买网项目的实例教程
    分享一个易买网项目的实例教程 向死而生 颜色分类:粉色
    型号:50ml
    产品很好,香味很喜欢,必须给赞。
    2015-09-24
    分享一个易买网项目的实例教程 就是这么想的 颜色分类:粉色
    型号:50ml
    送朋友,她很喜欢,大爱。
    2015-09-24
    分享一个易买网项目的实例教程 墨镜墨镜 颜色分类:粉色
    型号:50ml
    大家都说不错
    2015-09-24
    分享一个易买网项目的实例教程 那*****洋
    (匿名用户)
    颜色分类:粉色
    型号:50ml
    下次还会来买,推荐。
    2015-09-24

    上一页123...20下一页

    分享一个易买网项目的实例教程

    分享一个易买网项目的实例教程 您已成功收藏该商品
    查看我的关注 >>
    确定

    分享一个易买网项目的实例教程

    分享一个易买网项目的实例教程 宝贝已成功添加到购物车
    购物车共有1种宝贝(3件) 合计:1120元
    去购物车结算继续购物

    分享一个易买网项目的实例教程

    正品保障

    正品行货 放心购买
    分享一个易买网项目的实例教程

    满38包邮

    满38包邮 免运费
    分享一个易买网项目的实例教程

    天天低价

    天天低价 畅选无忧
    分享一个易买网项目的实例教程

    准时送达

    收货时间由你做主

    新手上路
    售后流程
    购物流程
    订购方式
    隐私声明
    推荐分享说明
    配送与支付
    货到付款区域
    配送支付查询
    支付方式说明
    会员中心
    资金管理
    我的收藏
    我的订单
    服务保证
    退换货原则
    售后服务保证
    产品质量保证
    联系我们
    网站故障报告
    购物咨询
    投诉与建议

    新浪微博 腾讯微博

    服务热线:
    400-123-4567

    分享一个易买网项目的实例教程

    分享一个易买网项目的实例教程

    备案/许可证编号:蜀ICP备12009302号-1-www.dingguagua.com Copyright © 2015-2018 尤洪商城网 All Rights Reserved. 复制必究 , Technical Support: Dgg Group
    分享一个易买网项目的实例教程分享一个易买网项目的实例教程分享一个易买网项目的实例教程分享一个易买网项目的实例教程分享一个易买网项目的实例教程分享一个易买网项目的实例教程

    <script src="js/ShopShow.js">

    商品详情图片的一个放大的效果:

    前台image图片的代码:

    分享一个易买网项目的实例教程

    Loading...

    引入外界的css和js:

      <script type="text/javascript" src="js/MagicZoom.js?1.1.11">

    MagicZoom.js代码:

    var MagicZoom_ua = 'msie';var W = navigator.userAgent.toLowerCase();if (W.indexOf("opera") != -1) { MagicZoom_ua = 'opera'} else if (W.indexOf("msie") != -1) { MagicZoom_ua = 'msie'} else if (W.indexOf("safari") != -1) { MagicZoom_ua = 'safari'} else if (W.indexOf("mozilla") != -1) { MagicZoom_ua = 'gecko'}var MagicZoom_zooms = new Array();function _el(id) {return document.getElementById(id)};function MagicZoom_getBounds(e) {if (e.getBoundingClientRect) {var r = e.getBoundingClientRect();var wx = 0;var wy = 0;if (document.body && (document.body.scrollLeft || document.body.scrollTop)) { wy = document.body.scrollTop; wx = document.body.scrollLeft } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) { wy = document.documentElement.scrollTop; wx = document.documentElement.scrollLeft }return {'left': r.left + wx,'top': r.top + wy,'right': r.right + wx,'bottom': r.bottom + wy } }}function MagicZoom_getEventBounds(e) {var x = 0;var y = 0;if (MagicZoom_ua == 'msie') { y = e.clientY; x = e.clientX;if (document.body && (document.body.scrollLeft || document.body.scrollTop)) { y = e.clientY + document.body.scrollTop; x = e.clientX + document.body.scrollLeft } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) { y = e.clientY + document.documentElement.scrollTop; x = e.clientX + document.documentElement.scrollLeft } } else { y = e.clientY; x = e.clientX; y += window.pageYOffset; x += window.pageXOffset }return {'x': x,'y': y }}function MagicView_ia() {return false};var MagicZoom_extendElement = function() {var args = arguments;if (!args[1]) args = [this, args[0]];for (var property in args[1]) args[0][property] = args[1][property];return args[0]};function MagicZoom_addEventListener(obj, event, listener) {if (MagicZoom_ua == 'gecko' || MagicZoom_ua == 'opera' || MagicZoom_ua == 'safari') {try { obj.addEventListener(event, listener, false) } catch(e) { alert("MagicZoom error: " + e + ", event=" + event) } } else if (MagicZoom_ua == 'msie') { obj.attachEvent("on" + event, listener) }};function MagicZoom_removeEventListener(obj, event, listener) {if (MagicZoom_ua == 'gecko' || MagicZoom_ua == 'opera' || MagicZoom_ua == 'safari') { obj.removeEventListener(event, listener, false) } else if (MagicZoom_ua == 'msie') { obj.detachEvent("on" + event, listener) }};function MagicZoom_concat() {var result = [];for (var i = 0; i < arguments.length; i++) for (var j = 0; j < arguments[i].length; j++) result.push(arguments[i][j]);return result};function MagicZoom_withoutFirst(sequence, skip) { result = [];for (var i = skip; i < sequence.length; i++) result.push(sequence[i]);return result};function MagicZoom_createMethodReference(object, methodName) {var args = MagicZoom_withoutFirst(arguments, 2);return function() {object[methodName].apply(object, MagicZoom_concat(arguments, args)) }};function MagicZoom_stopEventPropagation(e) {if (MagicZoom_ua == 'gecko' || MagicZoom_ua == 'safari' || MagicZoom_ua == 'opera') { e.cancelBubble = true; e.preventDefault(); e.stopPropagation() } else if (MagicZoom_ua == 'msie') { window.event.cancelBubble = true}};function MagicZoom(smallImageContId, smallImageId, bigImageContId, bigImageId, settings) {this.recalculating = false;this.smallImageCont = _el(smallImageContId);this.smallImage = _el(smallImageId);this.bigImageCont = _el(bigImageContId);this.bigImage = _el(bigImageId);this.pup = 0;this.settings = settings;if (!this.settings["header"]) {this.settings["header"] = ""}this.bigImageSizeX = 0;this.bigImageSizeY = 0;this.smallImageSizeX = 0;this.smallImageSizeY = 0;this.popupSizeX = 20;this.popupSizey = 20;this.positionX = 0;this.positionY = 0;this.bigImageContStyleLeft = '';this.loadingCont = null;if (this.settings["loadingImg"] != '') {this.loadingCont = document.createElement('DIV');this.loadingCont.style.position = 'absolute';this.loadingCont.style.visibility = 'hidden';this.loadingCont.className = 'MagicZoomLoading';this.loadingCont.style.display = 'block';this.loadingCont.style.textAlign = 'center';this.loadingCont.innerHTML = this.settings["loadingText"] + '
    ' + this.settings[';this.smallImageCont.appendChild(this.loadingCont) }this.baseuri = '';this.safariOnLoadStarted = false; MagicZoom_zooms.push(this);this.checkcoords_ref = MagicZoom_createMethodReference(this, "checkcoords")};MagicZoom.prototype.stopZoom = function() { MagicZoom_removeEventListener(window.document, "mousemove", this.checkcoords_ref);if (this.settings["position"] == "custom") { _el(this.smallImageCont.id + "-big").removeChild(this.bigImageCont) }};MagicZoom.prototype.checkcoords = function(e) {var y = 0;var x = 0; r = MagicZoom_getEventBounds(e); x = r['x']; y = r['y'];var smallY = 0;var smallX = 0;var tag = this.smallImage;while (tag && tag.tagName != "body" && tag.tagName != "HTML") { smallY += tag.offsetTop; smallX += tag.offsetLeft; tag = tag.offsetParent }if (MagicZoom_ua == 'msie') { r = MagicZoom_getBounds(this.smallImage); smallX = r['left']; smallY = r['top'] }if (x > parseInt(smallX + this.smallImageSizeX)) {this.hiderect();return false}if (x < parseInt(smallX)) {this.hiderect();return false}if (y > parseInt(smallY + this.smallImageSizeY)) {this.hiderect();return false}if (y < parseInt(smallY)) {this.hiderect();return false}if (MagicZoom_ua == 'msie') {this.smallImageCont.style.zIndex = 1}return true};MagicZoom.prototype.mousedown = function(e) { MagicZoom_stopEventPropagation(e);this.smallImageCont.style.cursor = 'move'};MagicZoom.prototype.mouseup = function(e) { MagicZoom_stopEventPropagation(e);this.smallImageCont.style.cursor = 'default'};MagicZoom.prototype.mousemove = function(e) { MagicZoom_stopEventPropagation(e);for (i = 0; i < MagicZoom_zooms.length; i++) {if (MagicZoom_zooms[i] != this) { MagicZoom_zooms[i].checkcoords(e) } }if (this.settings && this.settings["drag_mode"] == true) {if (this.smallImageCont.style.cursor != 'move') {return} }if (this.recalculating) {return}if (!this.checkcoords(e)) {return}this.recalculating = true;var smallImg = this.smallImage;var smallX = 0;var smallY = 0;if (MagicZoom_ua == 'gecko' || MagicZoom_ua == 'opera' || MagicZoom_ua == 'safari') {var tag = smallImg;while (tag.tagName != "body" && tag.tagName != "HTML") { smallY += tag.offsetTop; smallX += tag.offsetLeft; tag = tag.offsetParent } } else { r = MagicZoom_getBounds(this.smallImage); smallX = r['left']; smallY = r['top'] } r = MagicZoom_getEventBounds(e); x = r['x']; y = r['y'];this.positionX = x - smallX;this.positionY = y - smallY;if ((this.positionX + this.popupSizeX / 2) >= this.smallImageSizeX) {this.positionX = this.smallImageSizeX - this.popupSizeX / 2}if ((this.positionY + this.popupSizeY / 2) >= this.smallImageSizeY) {this.positionY = this.smallImageSizeY - this.popupSizeY / 2}if ((this.positionX - this.popupSizeX / 2) <= 0) {this.positionX = this.popupSizeX / 2}if ((this.positionY - this.popupSizeY / 2) <= 0) {this.positionY = this.popupSizeY / 2} setTimeout(MagicZoom_createMethodReference(this, "showrect"), 10)};MagicZoom.prototype.showrect = function() {this.pup.style.left = (this.positionX - this.popupSizeX / 2) + 'px';this.pup.style.top = (this.positionY - this.popupSizeY / 2) + 'px';this.pup.style.visibility = "visible"; perX = parseInt(this.pup.style.left) * (this.bigImageSizeX / this.smallImageSizeX); perY = parseInt(this.pup.style.top) * (this.bigImageSizeY / this.smallImageSizeY);this.bigImage.style.left = ( - perX) + 'px';this.bigImage.style.top = ( - perY) + 'px';this.bigImageCont.style.display = 'block';this.bigImageCont.style.visibility = 'visible';this.bigImage.style.display = 'block';this.bigImage.style.visibility = 'visible';this.recalculating = false;this.bigImageCont.style.left = this.bigImageContStyleLeft};MagicZoom.prototype.hiderect = function() {if (this.settings && this.settings["bigImage_always_visible"] == true) return;if (this.pup) {this.pup.style.visibility = "hidden"}this.bigImageCont.style.left = '-10000px';this.bigImageCont.style.visibility = 'hidden';if (MagicZoom_ua == 'msie') {this.smallImageCont.style.zIndex = 0}};MagicZoom.prototype.recalculatePopupDimensions = function() {this.popupSizeX = (parseInt(this.bigImageCont.style.width) - 0) / (this.bigImageSizeX / this.smallImageSizeX);if (this.settings && this.settings["header"] != "") {this.popupSizeY = (parseInt(this.bigImageCont.style.height) - 0 - 0) / (this.bigImageSizeY / this.smallImageSizeY) } else {this.popupSizeY = (parseInt(this.bigImageCont.style.height) - 0) / (this.bigImageSizeY / this.smallImageSizeY) }if (this.popupSizeX > this.smallImageSizeX) {this.popupSizeX = this.smallImageSizeX }if (this.popupSizeY > this.smallImageSizeY) {this.popupSizeY = this.smallImageSizeY }this.pup.style.width = this.popupSizeX + 'px';this.pup.style.height = this.popupSizeY + 'px'};MagicZoom.prototype.initPopup = function() {this.pup = document.createElement("DIV");this.pup.className = 'MagicZoomPup';this.pup.style.zIndex = 10;this.pup.style.visibility = 'hidden';this.pup.style.position = 'absolute';this.pup.style["opacity"] = parseFloat(this.settings['opacity'] / 100.0);this.pup.style["-moz-opacity"] = parseFloat(this.settings['opacity'] / 100.0);this.pup.style["-html-opacity"] = parseFloat(this.settings['opacity'] / 100.0);this.pup.style["filter"] = "alpha(Opacity=" + this.settings['opacity'] + ")";this.recalculatePopupDimensions();this.smallImageCont.appendChild(this.pup);this.smallImageCont.unselectable = "on";this.smallImageCont.style.MozUserSelect = "none";this.smallImageCont.onselectstart = MagicView_ia;this.smallImageCont.oncontextmenu = MagicView_ia};MagicZoom.prototype.initBigContainer = function() {var bigimgsrc = this.bigImage.src;while (this.bigImageCont.firstChild) {this.bigImageCont.removeChild(this.bigImageCont.firstChild) }if (MagicZoom_ua == 'msie') {var f = document.createElement("IFRAME"); f.style.left = '0px'; f.style.top = '0px'; f.style.position = 'absolute'; f.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)'; f.style.width = this.bigImageCont.style.width; f.style.height = this.bigImageCont.style.height; f.frameBorder = 0;this.bigImageCont.appendChild(f) }var ar1 = document.createElement("DIV"); ar1.style.overflow = "hidden";this.bigImageCont.appendChild(ar1);this.bigImage = document.createElement("IMG");this.bigImage.src = bigimgsrc;this.bigImage.style.position = 'relative'; ar1.appendChild(this.bigImage)};MagicZoom.prototype.initZoom = function() {if (this.loadingCont != null && !this.bigImage.complete && this.smallImage.width != 0 && this.smallImage.height != 0) {this.loadingCont.style.left = (parseInt(this.smallImage.width) / 2 - parseInt(this.loadingCont.offsetWidth) / 2) + 'px';this.loadingCont.style.top = (parseInt(this.smallImage.height) / 2 - parseInt(this.loadingCont.offsetHeight) / 2) + 'px';this.loadingCont.style.visibility = 'visible'}if (MagicZoom_ua == 'safari') {if (!this.safariOnLoadStarted) { MagicZoom_addEventListener(this.bigImage, "load", MagicZoom_createMethodReference(this, "initZoom"));this.safariOnLoadStarted = true;return} } else {if (!this.bigImage.complete || !this.smallImage.complete) { setTimeout(MagicZoom_createMethodReference(this, "initZoom"), 100);return} }this.bigImageSizeX = this.bigImage.width;this.bigImageSizeY = this.bigImage.height;this.smallImageSizeX = this.smallImage.width;this.smallImageSizeY = this.smallImage.height;if (this.bigImageSizeX == 0 || this.bigImageSizeY == 0 || this.smallImageSizeX == 0 || this.smallImageSizeY == 0) { setTimeout(MagicZoom_createMethodReference(this, "initZoom"), 100);return}if (this.loadingCont != null) this.loadingCont.style.visibility = 'hidden';this.smallImageCont.style.width = this.smallImage.width + 'px';this.bigImageCont.style.left = this.smallImage.width + 15 + 'px';this.bigImageCont.style.top = '0px';switch (this.settings['position']) {case 'left':this.bigImageCont.style.left = '-' + (15 + parseInt(this.bigImageCont.style.width)) + 'px';break;case 'bottom':this.bigImageCont.style.top = this.smallImage.height + 15 + 'px';this.bigImageCont.style.left = '0px';break;case 'top':this.bigImageCont.style.top = '-' + (15 + parseInt(this.bigImageCont.style.height)) + 'px';this.bigImageCont.style.left = '0px';break;case 'custom':this.bigImageCont.style.left = '0px';this.bigImageCont.style.top = '0px';break;case 'inner':this.bigImageCont.style.left = '0px';this.bigImageCont.style.top = '0px';break}this.bigImageContStyleLeft = this.bigImageCont.style.left;if (this.pup) {this.recalculatePopupDimensions();return}this.initBigContainer();this.initPopup(); MagicZoom_addEventListener(window.document, "mousemove", this.checkcoords_ref); MagicZoom_addEventListener(this.smallImageCont, "mousemove", MagicZoom_createMethodReference(this, "mousemove"));if (this.settings && this.settings["drag_mode"] == true) { MagicZoom_addEventListener(this.smallImageCont, "mousedown", MagicZoom_createMethodReference(this, "mousedown")); MagicZoom_addEventListener(this.smallImageCont, "mouseup", MagicZoom_createMethodReference(this, "mouseup"));this.positionX = this.smallImageSizeX / 2;this.positionY = this.smallImageSizeY / 2;this.showrect() }};MagicZoom.prototype.replaceZoom = function(e, ael) {if (ael.href == this.bigImage.src) return;var newBigImage = document.createElement("IMG"); newBigImage.id = this.bigImage.id; newBigImage.src = ael.getElementsByTagName("img")[0].getAttribute("tsImgS");var p = this.bigImage.parentNode; p.replaceChild(newBigImage, this.bigImage);this.bigImage = newBigImage;this.bigImage.style.position = 'relative';this.smallImage.src = ael.getElementsByTagName("img")[0].src;this.safariOnLoadStarted = false;this.initZoom()};function MagicZoom_findSelectors(id, zoom) {var aels = window.document.getElementsByTagName("li");for (var i = 0; i < aels.length; i++) {if (aels[i].getAttribute("rel") == id) { MagicZoom_addEventListener(aels[i], "click", function(event) {if (MagicZoom_ua != 'msie') {this.blur() } else { window.focus() } MagicZoom_stopEventPropagation(event);return false}); MagicZoom_addEventListener(aels[i], zoom.settings['thumb_change'], MagicZoom_createMethodReference(zoom, "replaceZoom", aels[i])); aels[i].style.outline = '0'; aels[i].mzextend = MagicZoom_extendElement; aels[i].mzextend({ zoom: zoom, selectThisZoom: function() {this.zoom.replaceZoom(null, this) } }) } }};function MagicZoom_stopZooms() {};function MagicZoom_findZooms() {var loadingText = 'Loading Zoom';var loadingImg = '';var iels = window.document.getElementsByTagName("IMG");for (var i = 0; i < iels.length; i++) {if (/MagicZoomLoading/.test(iels[i].className)) {if (iels[i].alt != '') loadingText = iels[i].alt; loadingImg = iels[i].src;break} }var aels = window.document.getElementsByTagName("A");for (var i = 0; i < aels.length; i++) {if (/MagicZoom/.test(aels[i].className)) {while (aels[i].firstChild) {if (aels[i].firstChild.tagName != 'IMG') { aels[i].removeChild(aels[i].firstChild) } else {break} }if (aels[i].firstChild.tagName != 'IMG') throw "Invalid MagicZoom invocation!";var rand = Math.round(Math.random() * 1000000); aels[i].style.position = "relative"; aels[i].style.display = 'block'; aels[i].style.outline = '0'; aels[i].style.textDecoration = 'none'; MagicZoom_addEventListener(aels[i], "click", function(event) {if (MagicZoom_ua != 'msie') {this.blur() } else { window.focus() } MagicZoom_stopEventPropagation(event);return false});if (aels[i].id == '') { aels[i].id = "sc" + rand }if (MagicZoom_ua == 'msie') { aels[i].style.zIndex = 0}var smallImg = aels[i].firstChild; smallImg.id = "sim" + rand;var bigCont = document.createElement("DIV"); bigCont.id = "bc" + rand; re = new RegExp(/opacity(\s+)?:(\s+)?(\d+)/i); matches = re.exec(aels[i].rel);var opacity = 50;if (matches) { opacity = parseInt(matches[3]) } re = new RegExp(/thumb\-change(\s+)?:(\s+)?(click|mouseover)/i); matches = re.exec(aels[i].rel);var thumb_change = 'click';if (matches) { thumb_change = matches[3] } re = new RegExp(/zoom\-width(\s+)?:(\s+)?(\w+)/i); matches = re.exec(aels[i].rel); bigCont.style.width = '300px';if (matches) { bigCont.style.width = matches[3] } re = new RegExp(/zoom\-height(\s+)?:(\s+)?(\w+)/i); matches = re.exec(aels[i].rel); bigCont.style.height = '297px';if (matches) { bigCont.style.height = matches[3] } re = new RegExp(/zoom\-position(\s+)?:(\s+)?(\w+)/i); matches = re.exec(aels[i].rel); bigCont.style.left = aels[i].firstChild.width + 15 + 'px'; bigCont.style.top = '0px';var position = 'right';if (matches) {switch (matches[3]) {case 'left': position = 'left';break;case 'bottom': position = 'bottom';break;case 'top': position = 'top';break;case 'custom': position = 'custom';break;case 'inner': position = 'inner';break} } re = new RegExp(/drag\-mode(\s+)?:(\s+)?(true|false)/i); matches = re.exec(aels[i].rel);var drag_mode = false;if (matches) {if (matches[3] == 'true') drag_mode = true} re = new RegExp(/always\-show\-zoom(\s+)?:(\s+)?(true|false)/i); matches = re.exec(aels[i].rel);var bigImage_always_visible = false;if (matches) {if (matches[3] == 'true') bigImage_always_visible = true} bigCont.style.overflow = 'hidden'; bigCont.className = "MagicZoomBigImageCont"; bigCont.style.zIndex = 100; bigCont.style.visibility = 'hidden';if (position != 'custom') { bigCont.style.position = 'absolute'} else { bigCont.style.position = 'relative'}var bigImg = document.createElement("IMG"); bigImg.id = "bim" + rand; bigImg.src = aels[i].href; bigCont.appendChild(bigImg);if (position != 'custom') { aels[i].appendChild(bigCont) } else { _el(aels[i].id + '-big').appendChild(bigCont) }var settings = { bigImage_always_visible: bigImage_always_visible, drag_mode: drag_mode, header: aels[i].title, opacity: opacity, thumb_change: thumb_change, position: position, loadingText: loadingText, loadingImg: loadingImg };var zoom = new MagicZoom(aels[i].id, 'sim' + rand, bigCont.id, 'bim' + rand, settings); aels[i].mzextend = MagicZoom_extendElement; aels[i].mzextend({ zoom: zoom }); zoom.initZoom(); MagicZoom_findSelectors(aels[i].id, zoom) } }};if (MagicZoom_ua == 'msie') try { document.execCommand("BackgroundImageCache", false, true)} catch(e) {};MagicZoom_addEventListener(window, "load", MagicZoom_findZooms);

    ShopShow.css和MagicZoom.css:

    .MagicZoomBigImageCont { border:1px solid #91b817; background:#FFF;}.MagicZoomMain { text-align: center !important; width: 92px;}.MagicZoomMain p { padding: 0px !important;}.MagicZoomHeader { font: 10px Tahoma, Verdana, Arial, sans-serif; color: #fff; background: #91b817; text-align: center !important; }.MagicZoomPup { border: 0px solid #aaa; background: #ffffff;}.MagicZoomLoading { text-align: center; background: #ffffff; color: #444; border: 1px solid #ccc; opacity: 0.8; padding: 3px 3px 3px 3px !important; display: none; }.MagicZoomLoading img { padding-top: 3px !important;}
    @charset "utf-8";html,body,ul,li,p{margin:0px;padding:0px;}li{list-style:none;}#tsShopContainer li,#tsShopContainer img{vertical-align:top;}#tsShopContainer{width:392px; height:495px; float:left; position:relative; }#tsShopContainer #tsImgS{text-align:center;width:100%;position:relative; border:1px solid #eaeaea; }#tsShopContainer #tsImgS a{display:block;text-align:center;margin:0px auto;}#tsShopContainer #tsImgS img{border:0px; width:390px; height:390px;}#tsShopContainer #tsPicContainer{width:100%;height:90px;position:relative;background:url(../images/scrollPicbg.gif) repeat-x 0px 0px; margin-top:10px; }#tsShopContainer #tsPicContainer #tsImgSArrL{width:15px;height:100%; background:url(../images/r_left.png) no-repeat left center; position:absolute;top:0px;left:0px;cursor:pointer;}#tsShopContainer #tsPicContainer #tsImgSArrR{width:15px;height:100%; background:url(../images/r_right.png) no-repeat right center; position:absolute;top:0px;right:0px;cursor:pointer;}#tsShopContainer #tsPicContainer #tsImgSCon{position:absolute;top:0px;left:18px;width:1px;height:90px;overflow:hidden; }#tsShopContainer #tsPicContainer #tsImgSCon ul{width:100%;overflow:hidden;}#tsShopContainer #tsPicContainer #tsImgSCon li{width:90px; float:left;cursor:pointer;}#tsShopContainer #tsPicContainer #tsImgSCon li img{padding:2px;margin:1px;border:1px solid #eaeaea; display:block;width:79px;height:79px;}#tsShopContainer #tsPicContainer #tsImgSCon li.tsSelectImg img{border:3px solid #ff4e00; padding:1px; margin:0px;}

     我的重难点:

    难点1: 在浏览中cookie的存取。 问题描述: 当用户浏览商品时将该用或浏览的当前商品id放入cookie中在”最近浏览“中显示用户浏览过的商品信息 难点:cookie中存放有SessionId如何区分SessionId和商品id? 解决方案: 在将商品id放入cookie中是将cookie的key值和value值设置为相同的值也就是商品的id(cookie中存放Sessionid的cookie的key值和value值不一样),然后在遍历cookie时对比其key值和value值是否相等(相等即商品id不相等则不是商品)

    难点2: 百度富文本编辑器中图片上传的配置 问题描述: 使用百度的文本富文本编辑器是传图片后不能在页面上显示 解决方案: 在ueditor的jsp文件夹下的config.json文件中配置正确的上传路径和访问访问路径。 imagePathFormat:图片上传后保存的路径相对于网站的根目录 imageUrlPrefix:图片的访问路径前缀相对于当前页面路径,其访问路径为imagerurlPrefix+imagePathFormat

    难点3: 商品分类信息的层级显示: 问题描述: 商品分类中存在父级分类和子分类。如何显示 解决方案: 分别查询出父级分类和子级分类类在遍历父级分类时遍历子级分类找出该父级分类的子分类进行显示 复制代码如下:

    商品分类

                       
                //遍历父级分类            
    ${pitem.EPC_NAME }
    //显示父分类             //遍历子级分类                                    
    ${citem.EPC_NAME }
               
               
            
                                               
           

    难点4:

    使用过滤器实现权限控制 问题描述: 如何区分哪些页面需要验证权限 解决方案: 将需要验证权限的页面设置统一格式的路径在Filter中使用正则表达式筛选出取药进行权限验证的页面进行权限验证,

     

    自在人与人

     

    标签: 易买网

    本文地址:https://www.lifejia.cn/news/211552.html

    免责声明:本站内容仅用于学习参考,信息和图片素材来源于互联网,如内容侵权与违规,请联系我们进行删除,我们将在三个工作日内处理。联系邮箱:cloudinto#qq.com(把#换成@)