基于javaweb+mysql的ssm眼镜商城系统(java+ssm+jsp+jquery+mysql)

基于javaweb+mysql的ssm眼镜商城系统(java+ssm+jsp+jquery+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SSM眼镜商城系统(java+ssm+jsp+jquery+mysql)

项目介绍

管理员角色包含以下功能: 管理员登录,管理员管理,管理商城会员,新闻公告管理,眼睛类型管理,城市信息管理,连锁配镜店管理,眼镜商品管理,用户订单管理,管理用户的评价信息等功能。

用户角色包含以下功能: 用户首页,查看站点公告,眼镜推荐,查看销售网络,用户登录,查看、评论商品、加入购物车,查看购物车,选择眼镜店信息,查看订单列表,修改个人信息等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库:MySql 5.7等版本均可;

技术栈

  1. 后端:Spring springmvc mybatis 2. 前端:JSP+css+javascript+jQuery

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2.使用IDEA/Eclipse/MyEclipse导入项目,配置tomcat 3. 将项目中springmvc-servlet.xml配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入http://localhost:8080/ 登录 用户账号/密码: user/123456 管理员账号/密码:admin/admin
		public String network() {
			this.front();
			List<Cate> cateList = this.cateService.getCateFront();
			List<Cate> frontList = new ArrayList<Cate>();
			for (Cate cate : cateList) {
				List<Jiancai> flimList = this.jiancaiService.getJiancaiByCate(cate.getCateid());
				cate.setFlimList(flimList);
				frontList.add(cate);
			}
			this.getRequest().setAttribute("frontList", frontList);
			return "users/network";
		}

	// 公告
	@RequestMapping("article.action")
	public String article(String number) {
		this.front();
		List<Article> articleList = new ArrayList<Article>();
		List<Article> tempList = this.articleService.getAllArticle();
		int pageNumber = tempList.size();
		int maxPage = pageNumber;
		if (maxPage % 12 == 0) {
			maxPage = maxPage / 12;
		} else {
			maxPage = maxPage / 12 + 1;
		}
		if (number == null) {
			number = "0";
		}
		int start = Integer.parseInt(number) * 12;
		int over = (Integer.parseInt(number) + 1) * 12;
		int count = pageNumber - over;
		if (count <= 0) {
			over = pageNumber;
		}
		for (int i = start; i < over; i++) {
			Article x = tempList.get(i);
			articleList.add(x);
		}
		String html = "";
			if ("ordercode".equals(cond)) {
				details.setOrdercode(name);
			}
			if ("jiancaiid".equals(cond)) {
				details.setJiancaiid(name);
			}
			if ("num".equals(cond)) {
				details.setNum(name);
			}
			if ("price".equals(cond)) {
				details.setPrice(name);
			}
			if ("cityid".equals(cond)) {
				details.setCityid(name);
			}
			if ("peihuoid".equals(cond)) {
				details.setPeihuoid(name);
			}
			if ("viewdate".equals(cond)) {
				details.setViewdate(name);
			}
		}

		List<String> nameList = new ArrayList<String>();
		List<String> valueList = new ArrayList<String>();
		nameList.add(cond);
		valueList.add(name);
		PageHelper.getPage(this.detailsService.getDetailsByLike(details), "details", nameList, valueList, 10, number, this.getRequest(),
				"query");
		name = null;
		cond = null;
		return "admin/querydetails";
	}

	// 按主键查询数据
	@RequestMapping("getDetailsById.action")
	public String getDetailsById(String id) {
		Details details = this.detailsService.getDetailsById(id);
		this.getRequest().setAttribute("details", details);
		List<Jiancai> jiancaiList = this.jiancaiService.getAllJiancai();
		this.getRequest().setAttribute("jiancaiList", jiancaiList);
		List<City> cityList = this.cityService.getAllCity();
		this.getRequest().setAttribute("cityList", cityList);
		List<Peihuo> peihuoList = this.peihuoService.getAllPeihuo();
		this.getRequest().setAttribute("peihuoList", peihuoList);
		return "admin/editdetails";
	}

	public DetailsService getDetailsService() {
		return detailsService;
	}


}

//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = "/orders" , produces = "text/plain;charset=utf-8")
public class OrdersAction extends BaseAction {
// 注入Service 由于标签的存在 所以不需要getter setter
@Autowired
@Resource
private OrdersService ordersService;
@Autowired
@Resource
private UsersService usersService;

// 准备添加数据
@RequestMapping("createOrders.action")
public String createOrders() {
List<Users> usersList = this.usersService.getAllUsers();
this.getRequest().setAttribute("usersList", usersList);
return "admin/addorders";
}
// 添加数据
@RequestMapping("addOrders.action")
public String addOrders(Orders orders) {
this.ordersService.insertOrders(orders);
return "redirect:/orders/createOrders.action";
}

// 通过主键删除数据
@RequestMapping("deleteOrders.action")
	@RequestMapping("cate.action")
	public String cate(String id, String number) {
		this.front();
		Jiancai goods = new Jiancai();
		goods.setCateid(id);
		List<Jiancai> flimList = new ArrayList<Jiancai>();
		List<Jiancai> tempList = this.jiancaiService.getJiancaiByCond(goods);
		int pageNumber = tempList.size();
		int maxPage = pageNumber;
		if (maxPage % 12 == 0) {
			maxPage = maxPage / 12;
		} else {
			maxPage = maxPage / 12 + 1;
		}
		if (number == null) {
			number = "0";
		}
		int start = Integer.parseInt(number) * 12;
		int over = (Integer.parseInt(number) + 1) * 12;
		int count = pageNumber - over;
		if (count <= 0) {
			over = pageNumber;
		}
		for (int i = start; i < over; i++) {
			Jiancai x = tempList.get(i);
			flimList.add(x);
		}
		String html = "";
		StringBuffer buffer = new StringBuffer();
		buffer.append("&nbsp;&nbsp;共为");
		buffer.append(maxPage);
		buffer.append("页&nbsp; 共有");
		buffer.append(pageNumber);
		buffer.append("条&nbsp; 当前为第");
		buffer.append((Integer.parseInt(number) + 1));
		buffer.append("页 &nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("首页");
		} else {
			buffer.append("<a href=\"index/cate.action?number=0&id=\" + id+ \"\">首页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("上一页");
		} else {
		}
		html = buffer.toString();
		this.getRequest().setAttribute("html", html);
		this.getRequest().setAttribute("ordersList", ordersList);
		return "users/orderlist";
	}

	// 准备付款
	@RequestMapping("prePay.action")
	public String prePay(String id) {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		this.getRequest().setAttribute("id", id);
		return "users/pay";
	}

	// 付款
	@RequestMapping("pay.action")
	public String pay(String id) {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		Orders orders = this.ordersService.getOrdersById(this.getRequest().getParameter("id"));
		orders.setStatus("已付款");
		this.ordersService.updateOrders(orders);
		return "redirect:/index/showOrders.action";
	}

	// 确认收货
	@RequestMapping("over.action")
	public String over(String id) {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		Orders orders = this.ordersService.getOrdersById(this.getRequest().getParameter("id"));
		orders.setStatus("已收货");
		this.ordersService.updateOrders(orders);
		return "redirect:/index/showOrders.action";
	}

	// 取消订单
	@RequestMapping("cancel.action")
	public String cancel(String id) {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {

	// 查询眼镜
	@RequestMapping("query.action")
	public String query(String name) {
		this.front();
		Jiancai goods = new Jiancai();
		goods.setJiancainame(name);
		List<Jiancai> flimList = this.jiancaiService.getJiancaiByLike(goods);
		this.getRequest().setAttribute("flimList", flimList);
		return "users/list";
	}

	// 眼镜详情
	@RequestMapping("detail.action")
	public String detail(String id) {
		this.front();
		Jiancai goods = this.jiancaiService.getJiancaiById(id);
		goods.setHits("" + (Integer.parseInt(goods.getHits()) + 1));
		this.jiancaiService.updateJiancai(goods);
		this.getRequest().setAttribute("goods", goods);
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		String userid = (String) this.getSession().getAttribute("userid");
		Topic topic = new Topic();
		topic.setJiancaiid(id);
		List<Topic> topicList = this.topicService.getTopicByCond(topic);
		this.getRequest().setAttribute("topicList", topicList);
		this.getRequest().setAttribute("tnum", topicList.size());
		return "users/detail";
	}

	@RequestMapping("addTopic.action")
	public String addTopic(Topic topic) {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		String userid = (String) this.getSession().getAttribute("userid");
		topic.setAddtime(VeDate.getStringDateShort());
		topic.setContents(this.getRequest().getParameter("contents"));
		topic.setJiancaiid(this.getRequest().getParameter("goodsid"));
		topic.setNum(this.getRequest().getParameter("num"));
		topic.setUsersid(userid);
		this.topicService.insertTopic(topic);
		return "redirect:/index/detail.action?id=" + topic.getJiancaiid();
		this.articleService.deleteArticle(id);
		return "redirect:/article/getAllArticle.action";
	}

	// 批量删除数据
	@RequestMapping("deleteArticleByIds.action")
	public String deleteArticleByIds() {
		String[] ids = this.getRequest().getParameterValues("articleid");
		for (String articleid : ids) {
			this.articleService.deleteArticle(articleid);
		}
		return "redirect:/article/getAllArticle.action";
	}

	// 更新数据
	@RequestMapping("updateArticle.action")
	public String updateArticle(Article article) {
		this.articleService.updateArticle(article);
		return "redirect:/article/getAllArticle.action";
	}

	// 显示全部数据
	@RequestMapping("getAllArticle.action")
	public String getAllArticle(String number) {
		List<Article> articleList = this.articleService.getAllArticle();
		PageHelper.getPage(articleList, "article", null, null, 10, number, this.getRequest(), null);
		return "admin/listarticle";
	}

	// 按条件查询数据 (模糊查询)
	@RequestMapping("queryArticleByCond.action")
	public String queryArticleByCond(String cond, String name, String number) {
		Article article = new Article();
		if (cond != null) {
			if ("title".equals(cond)) {
				article.setTitle(name);
			}
			if ("image".equals(cond)) {
				article.setImage(name);
			}
			if ("contents".equals(cond)) {
				article.setContents(name);
			}
			if ("addtime".equals(cond)) {
				article.setAddtime(name);
			}
			if ("hits".equals(cond)) {
				article.setHits(name);

//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = "/cate", produces = "text/plain;charset=utf-8")
public class CateAction extends BaseAction {
	// 注入Service 由于标签的存在 所以不需要getter setter
	@Autowired
	@Resource
	private CateService cateService;

	// 准备添加数据
	@RequestMapping("createCate.action")
	public String createCate() {
		return "admin/addcate";
	}

	// 添加数据
	@RequestMapping("addCate.action")
	public String addCate(Cate cate) {
		cate.setAddtime(VeDate.getStringDateShort());
		this.cateService.insertCate(cate);
		return "redirect:/cate/createCate.action";
	}

	// 通过主键删除数据
	@RequestMapping("deleteCate.action")
	public String deleteCate(String id) {
		this.cateService.deleteCate(id);
		return "redirect:/cate/getAllCate.action";
	}

	// 批量删除数据
	@RequestMapping("deleteCateByIds.action")
	public String deleteCateByIds() {

// 更新数据
@RequestMapping("updateUsers.action")
public String updateUsers(Users users) {
this.usersService.updateUsers(users);
return "redirect:/users/getAllUsers.action";
}
// 显示全部数据
@RequestMapping("getAllUsers.action")
public String getAllUsers(String number) {
List<Users> usersList = this.usersService.getAllUsers();
PageHelper.getPage(usersList, "users", null, null, 10, number, this.getRequest(), null);
return "admin/listusers";
}

// 按条件查询数据 (模糊查询)
@RequestMapping("queryUsersByCond.action")
public String queryUsersByCond(String cond, String name, String number) {
Users users = new Users();
if(cond != null){
if ("username".equals(cond)) {
users.setUsername(name);
}
if ("password".equals(cond)) {
users.setPassword(name);
}
if ("realname".equals(cond)) {
users.setRealname(name);
}
if ("sex".equals(cond)) {
users.setSex(name);
}
if ("birthday".equals(cond)) {
users.setBirthday(name);
}
if ("contact".equals(cond)) {
users.setContact(name);
}
if ("regdate".equals(cond)) {
users.setRegdate(name);
}
}
			this.usersService.insertUsers(users);
		} else {
			this.getSession().setAttribute("message", "用户名已存在");
			return "redirect:/index/preReg.action";
		}

		return "redirect:/index/preLogin.action";
	}

	// 退出登录
	@RequestMapping("exit.action")
	public String exit() {
		this.front();
		this.getSession().removeAttribute("userid");
		this.getSession().removeAttribute("username");
		this.getSession().removeAttribute("users");
		return "index";
	}

	// 准备修改密码
	@RequestMapping("prePwd.action")
	public String prePwd() {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		return "users/editpwd";
	}

	// 修改密码
	@RequestMapping("editpwd.action")
	public String editpwd() {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		String userid = (String) this.getSession().getAttribute("userid");
		String password = this.getRequest().getParameter("password");
		String repassword = this.getRequest().getParameter("repassword");
		Users users = this.usersService.getUsersById(userid);
		if (password.equals(users.getPassword())) {
			users.setPassword(repassword);
			this.usersService.updateUsers(users);
		} else {
			this.getSession().setAttribute("message", "旧密码错误");
	private PeihuoService peihuoService;
	@Autowired
	@Resource
	private CityService cityService;

	// 准备添加数据
	@RequestMapping("createPeihuo.action")
	public String createPeihuo() {
		List<City> cityList = this.cityService.getAllCity();
		this.getRequest().setAttribute("cityList", cityList);
		return "admin/addpeihuo";
	}

	// 添加数据
	@RequestMapping("addPeihuo.action")
	public String addPeihuo(Peihuo peihuo) {
		this.peihuoService.insertPeihuo(peihuo);
		return "redirect:/peihuo/createPeihuo.action";
	}

	// 通过主键删除数据
	@RequestMapping("deletePeihuo.action")
	public String deletePeihuo(String id) {
		this.peihuoService.deletePeihuo(id);
		return "redirect:/peihuo/getAllPeihuo.action";
	}

	// 批量删除数据
	@RequestMapping("deletePeihuoByIds.action")
	public String deletePeihuoByIds() {
		String[] ids = this.getRequest().getParameterValues("peihuoid");
		for (String peihuoid : ids) {
			this.peihuoService.deletePeihuo(peihuoid);
		}
		return "redirect:/peihuo/getAllPeihuo.action";
	}

	// 更新数据
	@RequestMapping("updatePeihuo.action")
	public String updatePeihuo(Peihuo peihuo) {
		this.peihuoService.updatePeihuo(peihuo);
		return "redirect:/peihuo/getAllPeihuo.action";
	}
		valueList.add(name);
		PageHelper.getPage(this.peihuoService.getPeihuoByLike(peihuo), "peihuo", nameList, valueList, 10, number, this.getRequest(), "query");
		name = null;
		cond = null;
		return "admin/querypeihuo";
	}

	// 按主键查询数据
	@RequestMapping("getPeihuoById.action")
	public String getPeihuoById(String id) {
		Peihuo peihuo = this.peihuoService.getPeihuoById(id);
		this.getRequest().setAttribute("peihuo", peihuo);
		List<City> cityList = this.cityService.getAllCity();
		this.getRequest().setAttribute("cityList", cityList);
		return "admin/editpeihuo";
	}

	public PeihuoService getPeihuoService() {
		return peihuoService;
	}

	public void setPeihuoService(PeihuoService peihuoService) {
		this.peihuoService = peihuoService;
	}

}

		this.getSession().removeAttribute("adminname");
		this.getSession().removeAttribute("realname");
		return "admin/index";
	}

	// 准备添加数据
	@RequestMapping("createAdmin.action")
	public String createAdmin() {
		return "admin/addadmin";
	}

	// 添加数据
	@RequestMapping("addAdmin.action")
	public String addAdmin(Admin admin) {
		admin.setAddtime(VeDate.getStringDateShort());
		this.adminService.insertAdmin(admin);
		return "redirect:/admin/createAdmin.action";
	}

	// 通过主键删除数据
	@RequestMapping("deleteAdmin.action")
	public String deleteAdmin(String id) {
		this.adminService.deleteAdmin(id);
		return "redirect:/admin/getAllAdmin.action";
	}

	// 批量删除数据
	@RequestMapping("deleteAdminByIds.action")
	public String deleteAdminByIds() {
		String[] ids = this.getRequest().getParameterValues("adminid");
		for (String adminid : ids) {
			this.adminService.deleteAdmin(adminid);
		}
		return "redirect:/admin/getAllAdmin.action";
	}

	// 更新数据
	@RequestMapping("updateAdmin.action")
	public String updateAdmin(Admin admin) {
		this.adminService.updateAdmin(admin);
		return "redirect:/admin/getAllAdmin.action";
	// 批量删除数据
	@RequestMapping("deleteArticleByIds.action")
	public String deleteArticleByIds() {
		String[] ids = this.getRequest().getParameterValues("articleid");
		for (String articleid : ids) {
			this.articleService.deleteArticle(articleid);
		}
		return "redirect:/article/getAllArticle.action";
	}

	// 更新数据
	@RequestMapping("updateArticle.action")
	public String updateArticle(Article article) {
		this.articleService.updateArticle(article);
		return "redirect:/article/getAllArticle.action";
	}

	// 显示全部数据
	@RequestMapping("getAllArticle.action")
	public String getAllArticle(String number) {
		List<Article> articleList = this.articleService.getAllArticle();
		PageHelper.getPage(articleList, "article", null, null, 10, number, this.getRequest(), null);
		return "admin/listarticle";
	}

	// 按条件查询数据 (模糊查询)
	@RequestMapping("queryArticleByCond.action")
	public String queryArticleByCond(String cond, String name, String number) {
		Article article = new Article();
		if (cond != null) {
			if ("title".equals(cond)) {
				article.setTitle(name);
			}
			if ("image".equals(cond)) {
				article.setImage(name);
			}
			if ("contents".equals(cond)) {
				article.setContents(name);
			}
			if ("addtime".equals(cond)) {
				article.setAddtime(name);
	@Resource
	private OrdersService ordersService;
	@Autowired
	@Resource
	private DetailsService detailsService;
	@Autowired
	@Resource
	private TopicService topicService;

	// 公共方法 提供公共查询数据
	private void front() {
		this.getRequest().setAttribute("title", "优品眼镜网-力作中国最大的眼镜网站");
		List<Cate> cateList = this.cateService.getAllCate();
		this.getRequest().setAttribute("cateList", cateList);
		List<Jiancai> hotList = this.jiancaiService.getJiancaiByHot();
		Collections.shuffle(hotList);
		this.getRequest().setAttribute("hotList", hotList);
	}

	// 首页显示
		@RequestMapping("index.action")
		public String index() {
			this.front();
			List<Cate> cateList = this.cateService.getCateFront();
			List<Cate> frontList = new ArrayList<Cate>();
			for (Cate cate : cateList) {
				List<Jiancai> flimList = this.jiancaiService.getJiancaiByCate(cate.getCateid());
				cate.setFlimList(flimList);
				frontList.add(cate);
			}
			this.getRequest().setAttribute("frontList", frontList);
			return "users/index";
		}
		
		// 首页显示
		@RequestMapping("network.action")
		public String network() {
			this.front();
			List<Cate> cateList = this.cateService.getCateFront();
			List<Cate> frontList = new ArrayList<Cate>();
			for (Cate cate : cateList) {
				List<Jiancai> flimList = this.jiancaiService.getJiancaiByCate(cate.getCateid());
				cate.setFlimList(flimList);
				frontList.add(cate);
			}
			this.getRequest().setAttribute("frontList", frontList);
			return "users/network";
		}

	// 公告
	@RequestMapping("article.action")
	public String article(String number) {
		this.front();
		List<Article> articleList = new ArrayList<Article>();
		int maxPage = pageNumber;
		if (maxPage % 12 == 0) {
			maxPage = maxPage / 12;
		} else {
			maxPage = maxPage / 12 + 1;
		}
		if (number == null) {
			number = "0";
		}
		int start = Integer.parseInt(number) * 12;
		int over = (Integer.parseInt(number) + 1) * 12;
		int count = pageNumber - over;
		if (count <= 0) {
			over = pageNumber;
		}
		for (int i = start; i < over; i++) {
			Article x = tempList.get(i);
			articleList.add(x);
		}
		String html = "";
		StringBuffer buffer = new StringBuffer();
		buffer.append("&nbsp;&nbsp;共为");
		buffer.append(maxPage);
		buffer.append("页&nbsp; 共有");
		buffer.append(pageNumber);
		buffer.append("条&nbsp; 当前为第");
		buffer.append((Integer.parseInt(number) + 1));
		buffer.append("页 &nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("首页");
		} else {
			buffer.append("<a href=\"index/article.action?number=0\">首页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("上一页");
		} else {
			buffer.append("<a href=\"index/article.action?number=" + (Integer.parseInt(number) - 1) + "\">上一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("下一页");
		} else {
			buffer.append("<a href=\"index/article.action?number=" + (Integer.parseInt(number) + 1) + "\">下一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("尾页");
		} else {
			buffer.append("<a href=\"index/article.action?number=" + (maxPage - 1) + "\">尾页</a>");
		}
		html = buffer.toString();
		this.getRequest().setAttribute("html", html);
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		this.usersService.updateUsers(users);
		return "redirect:/index/userinfo.action";
	}

	// 添加产品到购物车
	@RequestMapping("addcart.action")
	public String addcart() {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		String userid = (String) this.getSession().getAttribute("userid");
		Cart cart = new Cart();
		cart.setJiancaiid(getRequest().getParameter("goodsid"));
		cart.setNum(getRequest().getParameter("num"));
		cart.setPrice(getRequest().getParameter("price"));
		cart.setUsersid(userid);
		this.cartService.insertCart(cart);
		return "redirect:/index/cart.action";
	}

	// 查看购物车
	@RequestMapping("cart.action")
	public String cart() {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		String userid = (String) this.getSession().getAttribute("userid");
		Cart cart = new Cart();
		cart.setUsersid(userid);
		List<Cart> cartList = this.cartService.getCartByCond(cart);
		this.getRequest().setAttribute("cartList", cartList);
		return "users/cart";
	}

	// 删除购物车中的产品
	@RequestMapping("deletecart.action")
	public String deletecart(String id) {
			buffer.append("下一页");
		} else {
			buffer.append("<a href=\"index/all.action?number=" + (Integer.parseInt(number) + 1) + "\">下一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("尾页");
		} else {
			buffer.append("<a href=\"index/all.action?number=" + (maxPage - 1) + "\">尾页</a>");
		}
		html = buffer.toString();
		this.getRequest().setAttribute("html", html);
		this.getRequest().setAttribute("flimList", flimList);
		return "users/list";
	}

	// 查询眼镜
	@RequestMapping("query.action")
	public String query(String name) {
		this.front();
		Jiancai goods = new Jiancai();
		goods.setJiancainame(name);
		List<Jiancai> flimList = this.jiancaiService.getJiancaiByLike(goods);
		this.getRequest().setAttribute("flimList", flimList);
		return "users/list";
	}

	// 眼镜详情
	@RequestMapping("detail.action")
	public String detail(String id) {
		this.front();
		Jiancai goods = this.jiancaiService.getJiancaiById(id);
		goods.setHits("" + (Integer.parseInt(goods.getHits()) + 1));
		this.jiancaiService.updateJiancai(goods);
		this.getRequest().setAttribute("goods", goods);
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		String userid = (String) this.getSession().getAttribute("userid");
		Topic topic = new Topic();
		topic.setJiancaiid(id);
		List<Topic> topicList = this.topicService.getTopicByCond(topic);
		this.getRequest().setAttribute("topicList", topicList);
		this.getRequest().setAttribute("tnum", topicList.size());
		return "users/detail";
	}

	@RequestMapping("addTopic.action")
	public String addTopic(Topic topic) {

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值