网上书城的购物车功能(上)

本文主要介绍了网上书城购物车功能的实现,包括所需的vo实体类、web和xml配置,以及功能界面的js样式。在Eclipse的server.xml中进行了配置以解决图片映射问题,同时展示了购物车的界面设计,如index.jsp的首页、findBook.jsp的搜索页面和shopping.jsp的购物车界面。
摘要由CSDN通过智能技术生成

前言

之前修项目的时候经常图片加载不出来,是因为没有给图片做映射的结果,接下来是再卖给图片做映射的步骤,先在 Eclipse 中的Servers文件夹中找到server.xml,打开它滑到最底下找到这一行代码<Context docBase="mvc_book" path="/mvc_book" reloadable="true" source="org.eclipse.jst.jee.server:mvc_book"/>在他的上面添加一行代码和修改下

<Context docBase="E:/temps/2020/mvc/upload/" path="/uploadImages" />
      <Context docBase="mvc_book" path="/" reloadable="true" source="org.eclipse.jst.jee.server:mvc_book"/>

界面结果
在这里插入图片描述

购物车

所需的vo(实体类),web,xml配置

vo(实体类)

展示

package com.tang.vo;


import java.util.Objects;


public class ShopGoodsVo {
//    购物车列表订单项所需数据
    private String name;
    private float price;
    private int num;
    private float total;

//    提交订单所需数据
    private String consignee;
    private String phone;
    private String postalcode;
    private String address;
    private int sendType;

//    页面的所有传参字符串
    private String pageStr;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ShopGoodsVo that = (ShopGoodsVo) o;
        return Float.compare(that.price, price) == 0 &&
                num == that.num &&
                Float.compare(that.total, total) == 0 &&
                Objects.equals(name, that.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, price, num, total);
    }

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public float getPrice() {
		return price;
	}

	public void setPrice(float price) {
		this.price = price;
	}

	public int getNum() {
		return num;
	}

	public void setNum(int num) {
		this.num = num;
	}

	public float getTotal() {
		return total;
	}

	public void setTotal(float total) {
		this.total = total;
	}

	public String getConsignee() {
		return consignee;
	}

	public void setConsignee(String consignee) {
		this.consignee = consignee;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getPostalcode() {
		return postalcode;
	}

	public void setPostalcode(String postalcode) {
		this.postalcode = postalcode;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public int getSendType() {
		return sendType;
	}

	public void setSendType(int sendType) {
		this.sendType = sendType;
	}

	public String getPageStr() {
		return pageStr;
	}

	public void setPageStr(String pageStr) {
		this.pageStr = pageStr;
	}

	@Override
	public String toString() {
		return "ShopGoodsVo [name=" + name + ", price=" + price + ", num=" + num + ", total=" + total + ", consignee="
				+ consignee + ", phone=" + phone + ", postalcode=" + postalcode + ", address=" + address + ", sendType="
				+ sendType + ", pageStr=" + pageStr + "]";
	}

	public ShopGoodsVo(String name, float price, int num, float total, String consignee, String phone,
			String postalcode, String address, int sendType, String pageStr) {
		super();
		this.name = name;
		this.price = price;
		this.num = num;
		this.total = total;
		this.consignee = consignee;
		this.phone = phone;
		this.postalcode = postalcode;
		this.address = address;
		this.sendType = sendType;
		this.pageStr = pageStr;
	}

	public ShopGoodsVo() {
		super();
	}
    
    
}

web

bookAction (书籍名称搜索,书籍类别搜索)

 /*
	     * return null;
	     * ajax调用的时候,返回json数据,前台页面无刷新功能的时候,无需重定向或者转发
	     * 
	     * return "findBook";
	     * 需重定向或者转发
	     */
	    

	   public String search(HttpServletRequest request, HttpServletResponse response) {
	        PageBean pageBean = new PageBean();
	        pageBean.setRequest(request);
	        try {
	            List<Book> list = this.bookDao.list(book, pageBean);
	            request.setAttribute("books", list);
	            request.setAttribute("pageBean", pageBean);
	        } catch (Exception e) {
	            e.printStackTrace();
	        }
	        return "findBook";
	    }

	
<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值