精华内容
下载资源
问答
  • 1、此网页只是实现了管理员登录和商品管理两个模块。 2、其余的模块比如供货商管理,用户管理模块原理是一样的,怎么实现就你们自己实现吧。 3、我这个后台还有两个功能没有完善,就是管理员用户密码的加密传输,...
  • JAVAWEB:使用JSP+Servlet实现商品管理功能,后台为数据库,功能包括商品信息浏览、商品信息详情、商品信息删除及修改。
  • JAVAWEB使用JSP+Servlet实现商品管理功能,后台为数据库,功能包括商品信息浏览、商品信息详情、商品信息删除及修改。
  • JAVA WEB商品后台管理系统开发前言一、项目开发前准备二、项目开发1.创建数据库、数据表。2.读入数据总结 前言 1.本实例采用eclips javaee做开花环境,利用java开发商品后台功能实现,利用jsp做前端显示页面。运行...

    JAVA WEB商品后台管理系统开发


    前言

    1.本实例采用eclips javaee做开花环境,利用java开发商品后台功能实现,利用jsp做前端显示页面。运行在tomcat服务器上。
    2.实现了商品的添加、修改、查看、删除等功能。
    3.实例需求:tomcat服务器、eclipse javaee版本、jdk、jre、mysql数据库。
    

    一、项目开发前准备

        1.安装eclipse javaee版本的开花环境,下载安装jdk(jdk包含jre),下载安装mysql数据库,下载安装tomcat服务器
        2.cmd窗口测试jdk(java、javac),在eclipse配置tomcat服务器,测试tomcat服务器运行,测试MySQL安装是否成功。

    二、项目开发

    1.创建数据库、数据表。

    在这里插入图片描述

    2.创建项目目录导入相应的包

    在这里插入图片描述
    在这里插入图片描述

    3.书写前端页面

    在这里插入图片描述
    在这里插入图片描述

    4.java实现添加删除功能

    4.1链接数据库

    public class JDBCUtils {
    	//防止别人创建该类的实例
    	private JDBCUtils() {}
    	//创建一个连接池
    	public static ComboPooledDataSource pool=new ComboPooledDataSource();
    	//从连接池中获取一个连接对象,并返回
    	public static Connection getConn() throws SQLException{
    		return pool.getConnection();
    	}
    	//释放资源
    	public static void close(Connection conn,Statement ps,ResultSet rs) {
    		if(rs!=null) {
    			try {
    				rs.close();
    			} catch (SQLException e) {
    				e.printStackTrace();
    			}finally {
    				rs=null;
    			}
    		}
    		if(conn!=null) {
    			try {
    				conn.close();
    			} catch (SQLException e) {
    				e.printStackTrace();
    			}finally {
    				conn=null;
    			}
    		}
    		if(ps!=null) {
    			try {
    				ps.close();
    			} catch (SQLException e) {
    				e.printStackTrace();
    			}finally {
    				ps=null;
    			}
    		}
    	}
    }
    

    4.2查询数据库

    public List<Product> findProdList(){
    		Connection conn = null; 
    		PreparedStatement ps= null;
    		ResultSet rs = null;
    		try {
    			conn = JDBCUtils.getConn();
    			String sql = "select * from product";
    			ps = conn.prepareStatement(sql);
    			rs = ps.executeQuery();
    			//创建LIST集合用于封装
    			List<Product> list = new ArrayList<Product>();
    			Product prod = null;
    			while (rs.next()) {
    				prod = new Product();
    				prod .setId(rs.getInt("id"));
    				prod .setName(rs.getString("name"));
    				prod .setCategory(rs.getString("category"));
    				prod .setPrice(rs.getDouble("price"));
    				prod .setPnum(rs.getInt("pnum"));
    				prod .setDescription(rs.getString("description"));
    				list .add(prod);
    			}
    			return list;
    		}catch (SQLException e) {
    			e.printStackTrace();
    		}finally {
    			JDBCUtils.close(conn,ps,rs);
    		}
    		return null;
     
    	}
    

    总结

    1.因为篇幅原因此只实现了查询功能,且还有部分简单代码需自己添加,如:导包、跳转等需自己添加。
    2.此功能的是实现了,用户点击“商品管理”按钮,跳转网站同时Java实现数据库登录查询后饭回数据到前端页面。如还有什么疑问请添加好友:cruelYouX;
    展开全文
  • javaweb课程设计之商品后台管理系统

    千次阅读 2020-12-12 17:02:03
    基于java开发的商品管理系统,管理员在后台进行添加商品,修改商品,删除商品,批量删除商品,设置商品上下架功能等 完美实现,另外说明,该项目基于后台开发,前端展示暂时没做,后台写好了,前端展示很简单,无非...

    主要技术

    layui框架+html5+jsp+oracle数据库+servlet+session+filter........

    功能说明

    基于java开发的商品管理系统,管理员在后台进行添加商品,修改商品,删除商品,批量删除商品,设置商品上下架功能等

    完美实现,另外说明,该项目基于后台开发,前端展示暂时没做,后台写好了,前端展示很简单,无非调用几个变量

    该项目简单可以做一个课程设计,基本上包过,另外写一下前端高分不是问题

    项目展示

    登录界面

    用过滤器设置,未登录状态不可进入后台,强制跳转到登录界面,由于是后台展示,没有写注册,因为管理员只能在数据库添加或者运行java代码调用方法

    不是我不写注册,涉及到安全问题,如果写注册,任何一个人注册都有管理员权限,所以一般管理员是不具有注册权限的,除了前端登录

    商品管理

    登录进入商品管理,批量删除,删除,修改,添加,商品上下架等操作

    展开全文
  • 本系统是一套电商管理的系统,方便人们在线购买商品,方便商家后台管理自己的商品。 实现功能截图 功能点: (1) 登录功能:用户输入用户名和密码,进行登录验证。 (2) 注册功能:可以查询用户名是否已经存在,对注册...

    SSH-WEB商场系统

    本系统是一套电商管理的系统,方便人们在线购买商品,方便商家后台管理自己的商品。

    实现功能截图

    功能点:
    (1) 登录功能:用户输入用户名和密码,进行登录验证。
    (2) 注册功能:可以查询用户名是否已经存在,对注册信息进行验证。
    (3) 商品浏览:可以查询商品,显示商品详情,提供购买链接。
    (4) 购物车管理:欲购买商品可以增添到购物车,也可以从购物车删除商品。
    (5) 订单查询:用户登录后可以下订单,用户登录后也可以查看自己的订单。
    (6) 商品种类管理:管理员可以对商品种类进行添加、删除操作。
    (7) 商品管理:管理员可以添加商品、删除商品,查看所有商品。
    (8) 订单管理:管理员登录后可以对订单进行管理。
    (9) 用户管理:管理员可以管理注册用户信息。

    前台:

    用户注册登录:
    在这里插入图片描述
    在这里插入图片描述

    首页:
    在这里插入图片描述
    商品分类浏览:
    在这里插入图片描述
    商品详情:
    在这里插入图片描述
    购物车:
    在这里插入图片描述
    我的订单:
    在这里插入图片描述
    个人信息更新:
    在这里插入图片描述
    后台:

    管理员登录:
    在这里插入图片描述
    商品种类列表:
    在这里插入图片描述
    新增种类:
    在这里插入图片描述
    商品列表:
    在这里插入图片描述
    添加商品:
    在这里插入图片描述
    订单管理:
    在这里插入图片描述
    用户管理:
    在这里插入图片描述
    管理员密码修改:
    在这里插入图片描述

    主要流程图

    1、系统功能流程图:
    在这里插入图片描述
    在这里插入图片描述

    2、数据流图:
    顶层数据流图:
    在这里插入图片描述
    用户管理数据流图:
    在这里插入图片描述
    商品管理数据流图:
    在这里插入图片描述
    3、数据字典
    关键数据项:
    在这里插入图片描述

    技术点总结

    java框架:SSH
    jdk版本:1.7
    tomcat: 7.0
    数据库:mysql
    开发工具:myeclipse

    代码

    dao层:
    订单Dao:OrderDaoImpl.java

    package cn.itbaizhan.dao.impl;
    
    import java.util.List;
    
    import javax.annotation.Resource;
    
    
    
    
    import org.springframework.orm.hibernate3.HibernateTemplate;
    import org.springframework.stereotype.Component;
    
    import cn.itbaizhan.dao.OrderFormDao;
    import cn.itbaizhan.po.Commodity;
    import cn.itbaizhan.po.OrderForm;
    import cn.itbaizhan.po.User;
    @Component("orderFormDaoImpl")
    public class OrderFormDaoImpl implements OrderFormDao {
    //使用spring对Hibernate的模版 HibernateTemplate
    	@Resource(name="hibernateTemplate")
    	private HibernateTemplate hibernateTemplate;
    	
    	public void delete(OrderForm orderForm) {
    	hibernateTemplate.delete(orderForm);
    	}
    	@SuppressWarnings("unchecked")
    	public List<OrderForm> findAllOrderForms() {
    		String hql = "from OrderForm";
    		return (List<OrderForm>)hibernateTemplate.find(hql);
    	}
    
    	public OrderForm findOrderFormById(int id) {
    		OrderForm orderForm = (OrderForm)hibernateTemplate.get(OrderForm.class, id);
    		return orderForm;
    	}
    
    	public void save(OrderForm orderForm) {
    		System.out.println(orderForm);
    	 hibernateTemplate.save(orderForm);
    	}
    
    	public void update(OrderForm orderForm) {
    	hibernateTemplate.update(orderForm);
    
    	}
    	public HibernateTemplate getHibernateTmeplate() {
    		return hibernateTemplate;
    	}
    	public void setHibernateTmeplate(HibernateTemplate hibernateTemplate) {
    		this.hibernateTemplate = hibernateTemplate;
    	}
    	public OrderForm queryOrderForm(int orderFormId) {
    		
    		return (OrderForm)hibernateTemplate.getSessionFactory().openSession().createQuery(
    		"from OrderForm o where o.orderFormId=? ").setParameter(
    				0, orderFormId).uniqueResult();
    
    	}
    	@SuppressWarnings("unchecked")
    	public List<OrderForm> findOrderFormByUserName(String username) {
    		System.out.println("用户名:"+username);
    		String hql = "from OrderForm o where o.username=?";
    		
    		return (List<OrderForm>)hibernateTemplate.find(hql,username);
    	}
    	
    }
    
    

    AdminDaoImpl.java:

    package cn.itbaizhan.dao.impl;
    
    import java.util.List;
    
    import javax.annotation.Resource;
    
    
    
    
    import org.springframework.orm.hibernate3.HibernateTemplate;
    import org.springframework.stereotype.Component;
    
    import cn.itbaizhan.dao.AdminDao;
    import cn.itbaizhan.po.Admin;
    @Component("adminDaoImpl")
    public class AdminDaoImpl implements AdminDao {
    //使用spring对Hibernate的模版 HibernateTemplate
    	@Resource(name="hibernateTemplate")
    	private HibernateTemplate hibernateTemplate;
    	
    	public void delete(Admin admin) {
    	hibernateTemplate.delete(admin);
    	}
    	@SuppressWarnings("unchecked")
    	public List<Admin> findAllAdmins() {
    		String hql = "from Admin";
    		return (List<Admin>)hibernateTemplate.find(hql);
    	}
    
    	public Admin findAdminById(int id) {
    		Admin admin = (Admin)hibernateTemplate.get(Admin.class, id);
    		return admin;
    	}
    
    	public void save(Admin admin) {
    		System.out.println(admin);
    	 hibernateTemplate.save(admin);
    	}
    
    	public void update(Admin admin) {
    	hibernateTemplate.update(admin);
    
    	}
    	public HibernateTemplate getHibernateTmeplate() {
    		return hibernateTemplate;
    	}
    	public void setHibernateTmeplate(HibernateTemplate hibernateTemplate) {
    		this.hibernateTemplate = hibernateTemplate;
    	}
    	
    	//获取用户
    	public Admin getUserByLoginNameAndPassword(String username, String password) {
    		//String[] values={username, password}; 
    		//String hql = "from User u where u.username=? and u.password=?";
    		//(List<User>)hibernateTemplate.find(hql, values);
    		System.out.println("用户名:"+username);
    		
    		return  (Admin) hibernateTemplate.getSessionFactory().openSession().createQuery(
    		"from Admin a where a.username=? and a.password=?").setParameter(0, username).setParameter(1, password).uniqueResult();
    	}
    
    	
    
    }
    
    

    业务逻辑层(service)
    订单业务逻辑层:OrderServiceImpl.java

    package cn.itbaizhan.service.impl;
    
    import java.util.List;
    
    import javax.annotation.Resource;
    
    import org.springframework.stereotype.Component;
    
    import cn.itbaizhan.dao.OrderFormDao;
    import cn.itbaizhan.po.OrderForm;
    import cn.itbaizhan.po.User;
    import cn.itbaizhan.service.OrderFormService;
    //把类交给spring管理(如同配置bean节点)此类受spring事务管理
    @Component("orderFormServiceImpl")
    public class OrderFormServiceImpl implements OrderFormService {
    	//要调用dao层代码,所以要有OrderFormDao的对象,把其实现类靠spring注入
    	@Resource(name="orderFormDaoImpl")
    	private OrderFormDao orderFormDao;
    	public OrderFormDao getOrderFormDao() {
    		return orderFormDao;
    	}
    
    	public void setOrderFormDao(OrderFormDao orderFormDao) {
    		this.orderFormDao = orderFormDao;
    	}
    
    	public void delete(OrderForm orderForm) {
    		this.orderFormDao.delete(orderForm);
    
    	}
    	public List<OrderForm> findAllOrderForms() {
    		return this.orderFormDao.findAllOrderForms();
    	}
    	public OrderForm findOrderFormById(int id) {
    		
    		return this.orderFormDao.findOrderFormById(id);
    	}
    
    	public void save(OrderForm orderForm) {
    		this.orderFormDao.save(orderForm);
    
    	}
    
    	public void update(OrderForm orderForm) {
    		this.orderFormDao.update(orderForm);
    	}
    
    	public OrderForm queryOrderForm(int orderFormId) {
    		
    		return this.orderFormDao.queryOrderForm(orderFormId);
    	}
    
    	public List<OrderForm> findOrderFormByUserName(String username) {
    		
    		return this.orderFormDao.findOrderFormByUserName(username);
    	}
    
    	
    
    
    }
    
    

    管理员业务逻辑层:AdminServiceImpl.java

    package cn.itbaizhan.service.impl;
    
    import java.util.List;
    
    import javax.annotation.Resource;
    
    import org.springframework.stereotype.Component;
    
    import cn.itbaizhan.dao.AdminDao;
    import cn.itbaizhan.po.Admin;
    import cn.itbaizhan.service.AdminService;
    //把类交给spring管理(如同配置bean节点)此类受spring事务管理
    @Component("adminServiceImpl")
    public class AdminServiceImpl implements AdminService {
    	//要调用dao层代码,所以要有UserDao的对象,把其实现类靠spring注入
    	@Resource(name="adminDaoImpl")
    	private AdminDao adminDao;
    	public AdminDao getUserDao() {
    		return adminDao;
    	}
    
    	public void setUserDao(AdminDao adminDao) {
    		this.adminDao = adminDao;
    	}
    
    	public void delete(Admin user) {
    		this.adminDao.delete(user);
    
    	}
    	public List<Admin> findAllAdmins() {
    		return this.adminDao.findAllAdmins();
    	}
    	public Admin findAdminById(int id) {
    		// TODO Auto-generated method stub
    		return this.adminDao.findAdminById(id);
    	}
    
    	public void save(Admin admin) {
    		this.adminDao.save(admin);
    
    	}
    
    	public void update(Admin admin) {
    		this.adminDao.update(admin);
    	}
    
    
    	public Admin getUserByLoginNameAndPassword(String name, String password) {
    		
    		return this.adminDao.getUserByLoginNameAndPassword(name,password);
    	}
    
    
    }
    
    

    action层:
    订单action:OrderAction.java

    package cn.itbaizhan.action;
    
    import java.text.SimpleDateFormat;
    import java.util.Collection;
    import java.util.Date;
    import java.util.List;
    import java.util.Map;
    
    import javax.annotation.Resource;
    
    import org.springframework.context.annotation.Scope;
    import org.springframework.stereotype.Component;
    
    import cn.itbaizhan.action.*;
    import cn.itbaizhan.po.Commodity;
    import cn.itbaizhan.po.OrderForm;
    import cn.itbaizhan.po.User;
    import cn.itbaizhan.service.OrderFormService;
    import cn.itbaizhan.service.UserService;
    
    import com.opensymphony.xwork2.ActionContext;
    import com.opensymphony.xwork2.ActionSupport;
    
    @SuppressWarnings("serial")
    @Component("orderFormAction")
    @Scope("prototype")//多例,每个请求生成一个新的action
    public class OrderFormAction extends ActionSupport {
    	private OrderForm orderForm;
    	
    //要调用OrderFormService的方法,所以要声明,让spring把其实现类注入
    	@Resource(name="orderFormServiceImpl")
    	OrderFormService service;
    	
    	private UserService userservice;
    	
    	public OrderFormService getService() {
    		return service;
    	}
    
    	public void setService(OrderFormService service) {
    		this.service = service;
    	}
    
    	public OrderForm getOrderForm() {
    		return orderForm;
    	}
    
    	public void setOrderForm(OrderForm orderForm) {
    		this.orderForm = orderForm;
    	}
    	
    
    	@Resource
    	public void setUserservice(UserService userservice) {
    		this.userservice = userservice;
    	}
    
    
    	public UserService getUserservice() {
    		return userservice;
    	}
    
    	@Override
    	public String execute() throws Exception {
    		// 不要直接访问数据库,应该访问业务逻辑层service,而service去访问DAO,DAO去访问数据库
    			this.service.save(this.orderForm);
    			System.out.println("orderForm:"+orderForm.getUsername());
    			ActionContext.getContext().put("ordermessage", "您的订单已经提交!");
    			return "success";
    	}
    	//列表
    	@SuppressWarnings("unchecked")
    	public String listOrderForm(){
    		Map request = (Map) ActionContext.getContext().get("request");
    		
    		request.put("listOrderForms", service.findAllOrderForms());
    		System.out.println("listOrderForms");
    		return "listOrderForm";
    	}
    	//查询
    	@SuppressWarnings("unchecked")
    	public String queryOrderForm(){
    		int orderFormId= orderForm.getOrderFormId();
    		System.out.println("orderFormId:"+orderFormId);
    		String username= orderForm.getUsername();
    		System.out.println("username:"+username);
    		String submitTime= orderForm.getSubmitTime();
    		System.out.println("submitTime:"+submitTime);
    		String consignmentTime= orderForm.getConsignmentTime();
    		System.out.println("consignmentTime:"+consignmentTime);
    	
    		OrderForm orderForm=this.service.queryOrderForm(orderFormId);
    		Map request=(Map) ActionContext.getContext().get("request");
    		
    		request.put("queryOrder", orderForm);
    		return "queryOrder";
    	}
    	
    
    	public String deleteOrderForm(){
    		this.service.delete(orderForm);
    		return "deleteOrderForm";
    	}
    	public String findOrderFormById(){
    		orderForm = this.service.findOrderFormById(orderForm.getOrderFormId());
    		return "findOrderForm";
    	}
    	//付款
    	@SuppressWarnings("unchecked")
    	public String payOrderForm(){
    		double totalprice=orderForm.getTotalPrice();//订单总金额
    		User user=userservice.findUserByName(orderForm.getUsername());
    		double money=user.getMoney();//用户所有金钱
    		Map request = (Map) ActionContext.getContext().get("request");
    		if(totalprice>money){		
    			request.put("nowOrder", orderForm);
    			ActionContext.getContext().put("payemessage", "您的金额不足!");
    		}
    		else
    		{
    		user.setMoney(money-totalprice);
    		userservice.update(user);
    		orderForm.setIsPayoff("是");
    		this.service.update(orderForm);
    		
    		System.out.println("orderForm:"+orderForm.getOrderFormId());
    		
    		request.put("nowOrder", orderForm);
    		ActionContext.getContext().put("payemessage", "付款成功!");
    		}
    		return "payOrderForm";
    	}
    	
    	//订单列表付款
    	@SuppressWarnings("unchecked")
    	public String payOrder(){
    		double totalprice=orderForm.getTotalPrice();//订单总金额
    		String username=orderForm.getUsername();
    		User user=userservice.findUserByName(orderForm.getUsername());
    		double money=user.getMoney();//用户所有金钱
    		
    		Map request = (Map) ActionContext.getContext().get("request");
    		
    		if(totalprice>money){
    	
    			request.put("orderFormByUserName", service.findOrderFormByUserName(username));
    			ActionContext.getContext().put("payemessage", "您的金额不足!");
    		}
    		else
    		{
    		user.setMoney(money-totalprice);
    		userservice.update(user);
    		orderForm.setIsPayoff("是");
    		this.service.update(orderForm);
    		System.out.println("orderForm:"+orderForm.getOrderFormId());
    		
    		request.put("orderFormByUserName", service.findOrderFormByUserName(username));
    		ActionContext.getContext().put("payemessage", "付款成功!");
    		}
    		return "payOrder";
    	}
    	
    	public String inputOrderForm(){
    		return "input";
    	}
    	//发货
    	@SuppressWarnings("unchecked")
    	public String conOrder(){
    		orderForm.setIsConsignment("是");
    		this.service.update(orderForm);
    		Map request = (Map) ActionContext.getContext().get("request");
    		request.put("listOrderForms", service.findAllOrderForms());
    		
    		return "conOrder";
    	}
    	//提交订单
    	@SuppressWarnings("unchecked")
    	public String addOrderForm(){
    		this.service.save(this.orderForm);
    		
    		Map session = ActionContext.getContext().getSession();//获得session对象
    		List<Commodity> car = (List<Commodity>)session.get("car");//取得购物车
    		car.clear();
    		
    		Map request = (Map) ActionContext.getContext().get("request");
    		request.put("nowOrder",orderForm);
    		return "addOrderForm";
    	}
    	
    	@SuppressWarnings("unchecked")
    	public String findOrderFormByUserName(){
    		Map request = (Map) ActionContext.getContext().get("request");
    		
    		request.put("orderFormByUserName",this.service.findOrderFormByUserName(orderForm.getUsername()));
    		return "findOrderFormByUserName";
    	}
    	
    }
    
    

    管理员action:AdminAction.java

    package cn.itbaizhan.action;
    
    import java.util.Collection;
    import java.util.Map;
    
    import javax.annotation.Resource;
    
    import org.springframework.context.annotation.Scope;
    import org.springframework.stereotype.Component;
    
    import cn.itbaizhan.po.Admin;
    import cn.itbaizhan.service.AdminService;
    
    import com.opensymphony.xwork2.ActionContext;
    import com.opensymphony.xwork2.ActionSupport;
    
    
    
    @SuppressWarnings("serial")
    @Component("adminAction")
    @Scope("prototype")//多例,每个请求生成一个新的action
    public class AdminAction extends ActionSupport {
    	private Admin admin;
    	
    	//private Role role;
    	//private Department department;
    //要调用UserService的方法,所以要声明,让spring把其实现类注入
    	@Resource(name="adminServiceImpl")
    	AdminService service;
    	public AdminService getService() {
    		return service;
    	}
    
    	public void setService(AdminService service) {
    		this.service = service;
    	}
    
    	public Admin getAdmin() {
    		return admin;
    	}
    
    	public void setAdmin(Admin admin) {
    		this.admin = admin;
    	}
    	
    	@SuppressWarnings("unchecked")
    	public String listAdmin(){
    		Map request = (Map) ActionContext.getContext().get("request");
    		
    		request.put("list", service.findAllAdmins());
    		return "listAdmin";
    	}
    	public String deleteAdmin(){
    		this.service.delete(admin);
    		return "deleteAdmin";
    	}
    	public String findAdminById(){
    		admin = this.service.findAdminById(admin.getAdminId());
    		return "findAdmin";
    	}
    	public String updateAdmin(){
    		//adminpassmessage
    		
    		this.service.update(admin);
    		System.out.println("admin:"+admin.getUsername());
    		ActionContext.getContext().put("upAdminMessage", "密码修改成功!");	
    		return "updateAdmin";
    		
    	}
    	public String inputAdmin(){
    		return "input";
    	}
    	
    	@SuppressWarnings("unchecked")
    	public String addAdmin(){
    		Map request = (Map) ActionContext.getContext().get("request");
    		
    		return "addAdmin";
    	}
    
    	//管理员登录
    	public String login(){
    		String username= admin.getUsername();
    		System.out.println(username);
    		String password=admin.getPassword();
    
    		Admin admin = service.getUserByLoginNameAndPassword(username,password);
    		System.out.print("name:"+username+",pass:"+password+",user:"+admin);
    		if(admin == null){
    			ActionContext.getContext().put("message", "用户名或密码错误");		
    			return "login";
    		}else{
    			ActionContext.getContext().getSession().put("admin", admin);
    			return "index";
    		}
    	}
    	//退出
    	public String logout(){
    		ActionContext.getContext().getSession().clear();
    		return "logout";
    	}
    }
    
    

    写在最后

    码代码不容易,需要的同学可以参考学习,全部代码不能都贴出,如果需要可以+博主V交流获取(Code2Life2)
    最后,别忘了一键三连哦

    展开全文
  • 用JAVA+JSP+Struts2+Hibernate做的网上商城,做得比较全面,有用户模块、商品浏览模块(最新商品、热销商品、顾客推荐商品、点击率排行商品、销售排行商品)、用户投诉、购物车模块、订单模块等,当然还有后台管理,...
  • jsp商品销售管理系统

    2012-05-18 14:15:33
    系统设计与论文,商品在线销售管理系统。系统功能有交易管理、进货统计管理、销售统计管理、 员工销售业绩考核等。系统的主要模块有:用户功能模块,系统交易模块,数据库查看模块,后台管理模块等。
  • 网上拍卖解决方案作为网络消费者与网站商家进行网络交易的平台,旨在为广大网上商家提供一个安全、可靠、可全面支持商品销售的电子商务运营平台,浏览者或潜在客户在这个平台上可以进行商品的查看、搜索、交易、交流...

    基于B2C的网上拍卖系统

    网上拍卖解决方案作为网络消费者与网站商家进行网络交易的平台,旨在为广大网上商家提供一个安全、可靠、可全面支持商品销售的电子商务运营平台,浏览者或潜在客户在这个平台上可以进行商品的查看、搜索、交易、交流。系统集会员、产品展示、订购系统、订单管理、促销管理、分类搜索、在线支付于一身。

    功能截图:

    登录页面:
    在这里插入图片描述
    首页:
    在这里插入图片描述
    促销:
    在这里插入图片描述
    秒杀:
    在这里插入图片描述
    竞拍:
    在这里插入图片描述
    留言:
    在这里插入图片描述
    购物车:
    在这里插入图片描述
    后台登录:
    在这里插入图片描述
    留言列表:
    在这里插入图片描述
    后台主页:
    在这里插入图片描述

    支付:
    在这里插入图片描述

    技术点介绍

    开发工具:Eclipse 。
    运行环境:jdk1.7
    服务器:Tomcat 7.0。
    数据库:MySql。
    操作系统:Windows 7

    需求

    1、用例图:
    在这里插入图片描述
    2、系统E-R图:
    在这里插入图片描述

    源码(部分)

    1、bean类:Order.java:

    package cn.itbaizhan.bean;
    
    import org.nutz.dao.entity.annotation.Column;
    import org.nutz.dao.entity.annotation.Id;
    import org.nutz.dao.entity.annotation.One;
    import org.nutz.dao.entity.annotation.Table;
    
    @Table("order1")
    public class Order {
    	@Id
    	private int id;
    	@Column("proid")
    	private int proid;
    	@One(target = Product.class, field = "proid")
    	private Product product;
    	@Column("count")
    	private String count;
    	@Column("singleprice")
    	private String singleprice;
    	@Column("price")
    	private String price;
    	@Column("userid")
    	private int userid;
    	
    	@One(target = User.class, field = "userid")
    	private User user;
    	
    	@Column("sffk")
    	private int sffk;
    	@Column("tel")
    	private String tel;
    	@Column("address")
    	private String address;
    	@Column("date")
    	private String date;
    	@Column("senddept")
    	private String senddept;
    	@Column("visible")
    	private int visible;
    	public int getId() {
    		return id;
    	}
    	public void setId(int id) {
    		this.id = id;
    	}
    	public String getCount() {
    		return count;
    	}
    	public void setCount(String count) {
    		this.count = count;
    	}
    	public String getPrice() {
    		return price;
    	}
    	public void setPrice(String price) {
    		this.price = price;
    	}
    	public int getSffk() {
    		return sffk;
    	}
    	public void setSffk(int sffk) {
    		this.sffk = sffk;
    	}
    	public String getDate() {
    		return date;
    	}
    	public void setDate(String date) {
    		this.date = date;
    	}
    	public String getSenddept() {
    		return senddept;
    	}
    	public void setSenddept(String senddept) {
    		this.senddept = senddept;
    	}
    	public String getTel() {
    		return tel;
    	}
    	public void setTel(String tel) {
    		this.tel = tel;
    	}
    	public String getAddress() {
    		return address;
    	}
    	public void setAddress(String address) {
    		this.address = address;
    	}
    	public Product getProduct() {
    		return product;
    	}
    	public void setProduct(Product product) {
    		this.product = product;
    	}
    	public User getUser() {
    		return user;
    	}
    	public void setUser(User user) {
    		this.user = user;
    	}
    	public int getProid() {
    		return proid;
    	}
    	public void setProid(int proid) {
    		this.proid = proid;
    	}
    	public int getUserid() {
    		return userid;
    	}
    	public void setUserid(int userid) {
    		this.userid = userid;
    	}
    	public String getSingleprice() {
    		return singleprice;
    	}
    	public void setSingleprice(String singleprice) {
    		this.singleprice = singleprice;
    	}
    	public int getVisible() {
    		return visible;
    	}
    	public void setVisible(int visible) {
    		this.visible = visible;
    	}
    	
    	
    }
    
    

    User.java:

    package cn.itbaizhan.bean;
    
    import org.nutz.dao.entity.annotation.Column;
    import org.nutz.dao.entity.annotation.Id;
    import org.nutz.dao.entity.annotation.Table;
    
    @Table("user")
    public class User {
    	@Id
    	private int id;
    	@Column("username")
    	private String username;
    	@Column("password")
    	private String password;
    	@Column("sex")
    	private int sex;
    	@Column("email")
    	private String email;
    	@Column("admin")
    	private int admin;
    	
    	public int getAdmin() {
    		return admin;
    	}
    	public void setAdmin(int admin) {
    		this.admin = admin;
    	}
    	public int getId() {
    		return id;
    	}
    	public void setId(int id) {
    		this.id = id;
    	}
    	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 int getSex() {
    		return sex;
    	}
    	public void setSex(int sex) {
    		this.sex = sex;
    	}
    	public String getEmail() {
    		return email;
    	}
    	public void setEmail(String email) {
    		this.email = email;
    	}
    	
    }
    
    

    2、业务逻辑类:(订单处理逻辑)OrderService.java:

    package cn.itbaizhan.service;
    
    import java.util.List;
    
    import org.nutz.dao.Cnd;
    import org.nutz.ioc.loader.annotation.IocBean;
    
    import cn.itbaizhan.bean.Order;
    import cn.itbaizhan.bean.User;
    
    @IocBean(name="orderService",fields={"dao"})
    public class OrderService extends BaseService{
    	/**
    	 * 
    	 * @param userid
    	 * @param proid
    	 * @return
    	 */
    	public List<Order> findOrderByUseridAndProid(int userid,int proid){
    		List<Order> list = dao.query(Order.class, Cnd.wrap("userid = "+userid+" AND proid = "+proid+" and sffk = 0 and visible = 1"), null);
    		return list;
    	}
    	public List<Order> findOrderByProid(int proid){
    		List<Order> list = dao.query(Order.class, Cnd.wrap("proid = "+proid+" and sffk = 0 and visible = 1 "), null);
    		return list;
    	}
    	
    	public List<Order> findOrderByProid1(int proid){
    		List<Order> list = dao.query(Order.class, Cnd.wrap("proid = "+proid+" and sffk = 0 and visible = 0 "), null);
    		return list;
    	}
    	/**
    	 * 添加cart
    	 * @param id
    	 * @return
    	 */
    	public Order addOrder(Order order){
    		return dao.insert(order);
    	}
    	/**
    	 * 购物车列表
    	 * @return
    	 */
    	public List<Order> getCartList(int id){
    		return dao.query(Order.class, Cnd.wrap("userid="+id+" and sffk=0  and visible = 1 order by id desc"), null);
    	}
    	
    	/**
    	 * 已购物品
    	 * @return
    	 */
    	public List<Order> getOrderList(int id){
    		return dao.query(Order.class, Cnd.wrap("userid="+id+" and sffk=1 and visible = 1 order by date desc"), null);
    	}
    	/**
    	 * 
    	 * @return
    	 */
    	public List<Order> getAllOrderList(){
    		return dao.query(Order.class, Cnd.wrap("sffk=1"), null);
    	}
    	/**
    	 * 根据ID查询
    	 */
    	public Order findOrderById(int id){
    		Order order = dao.fetch(Order.class, id);
    		return order;
    	}
    	/**
    	 * 修改
    	 * @param id
    	 * @return
    	 */
    	public int editOrder(Order order){
    		return dao.update(order);
    	}
    	/**
    	 * 删除
    	 * @param id
    	 * @return
    	 */
    	public int deleteOrder(int id){
    		return dao.delete(Order.class, id);
    	}
    }
    
    

    UserSerVice.java:

    package cn.itbaizhan.service;
    
    import java.util.List;
    
    import org.nutz.dao.Cnd;
    import org.nutz.dao.pager.Pager;
    import org.nutz.ioc.loader.annotation.IocBean;
    
    import cn.itbaizhan.bean.User;
    
    @IocBean(name="userService",fields={"dao"})
    public class UserService extends BaseService{
    
    	public List<User> findUserByNameAndPsd(String username,String password){
    		List<User> list = dao.query(User.class, Cnd.wrap("username = '"+username+"' AND password = '"+password+"'"), null);
    		return list;
    	}
    	/**
    	*查询人员
    	*/
    	public List<User> findUsers(Pager pager,String sortnameParmName,String sortorderParmName){
    		return dao.query(User.class,Cnd.wrap("ORDER BY "+sortnameParmName+" "+sortorderParmName),pager);
    	}
    	/**
    	*查询全部人员
    	*/
    	public List<User> findListUsers(){
    		return dao.query(User.class,null);
    	}
    	
    	/**
    	 * 查询人员总数
    	 * @return
    	 */
    	public int findUsersCount(){
    		return dao.count(User.class);
    	}
    	/**
    	 * 添加人员
    	 * @param id
    	 * @return
    	 */
    	public User addUser(User user){
    		return dao.insert(user);
    	}
    	/**
    	 * 根据ID查询
    	 */
    	public User findUserById(int id){
    		User user = dao.fetch(User.class, id);
    		return user;
    	}
    	/**
    	 * 修改人员
    	 * @param id
    	 * @return
    	 */
    	public int editUser(User user){
    		return dao.update(user);
    	}
    	
    	/**
    	 * 删除人员
    	 * @param id
    	 * @return
    	 */
    	public int deleteUser(int id){
    		return dao.delete(User.class, id);
    	}
    }
    
    

    3、Action类:OrderAction.java:

    package cn.itbaizhan.action;
    
    import java.text.DateFormat;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.Date;
    import java.util.List;
    
    import javax.servlet.http.HttpServletRequest;
    
    import org.nutz.ioc.loader.annotation.Inject;
    import org.nutz.ioc.loader.annotation.IocBean;
    import org.nutz.mvc.View;
    import org.nutz.mvc.annotation.At;
    import org.nutz.mvc.view.JspView;
    
    import cn.itbaizhan.bean.Order;
    import cn.itbaizhan.bean.Product;
    import cn.itbaizhan.bean.User;
    import cn.itbaizhan.common.PagerUtil;
    import cn.itbaizhan.service.OrderService;
    import cn.itbaizhan.service.ProductService;
    import cn.itbaizhan.service.UserService;
    
    @IocBean
    @At("/order")
    public class OrderAction {
    	
    	@Inject("refer:orderService")
    	private OrderService orderService;
    	@Inject("refer:productService")
    	private ProductService productService;
    	@Inject("refer:userService")
    	private UserService userService;
    	
    	/**
    	 * add order
    	 * @param request
    	 * @return
    	 */
    	@At("/add")
    	public View list(HttpServletRequest request){
    		String id = request.getParameter("id");
    		String price = request.getParameter("price");
    		User user = (User)request.getSession().getAttribute("user");
    		Order order = new Order();
    		order.setProid(Integer.parseInt(id));
    		List<Order> listOrd = orderService.findOrderByUseridAndProid(user.getId(), Integer.parseInt(id));
    		if(listOrd.size()>0){
    			Order existorder = listOrd.get(0);
    			int count = Integer.parseInt(existorder.getCount())+1;
    			int newprice = count* Integer.parseInt(existorder.getSingleprice());
    			existorder.setCount(String.valueOf(count));
    			existorder.setVisible(1);
    			existorder.setPrice(String.valueOf(newprice));
    			orderService.editOrder(existorder);
    		}else{
    			order.setSingleprice(price);
    			order.setPrice(price);
    			order.setCount("1");
    			order.setVisible(1);
    			order.setUserid(user.getId());
    			order = orderService.addOrder(order);
    			if(order!=null){
    				request.setAttribute("msg", "添加成功");
    			}else{
    				request.setAttribute("msg", "添加失败");
    			}
    		}
    		List<Order> list = orderService.getCartList(user.getId());
    		request.setAttribute("list", list);
    		int sumprice = 0;
    		for(int i=0;i<list.size();i++){
    			list.get(i).setUser(userService.findUserById(list.get(i).getUserid()));
    			list.get(i).setProduct(productService.findProductById(list.get(i).getProid()));
    			if(sumprice==0){
    				sumprice = Integer.parseInt(list.get(i).getPrice());
    			}else{
    				sumprice += Integer.parseInt(list.get(i).getPrice());
    			}
    		}
    		request.setAttribute("sumprice", sumprice);
    		request.setAttribute("count", list.size());
    		return new JspView("jsp.cart");
    	}
    	/**
    	 * 
    	 * @param request
    	 * @return
    	 */
    	@At("/changeCount")
    	public View changeCount(HttpServletRequest request){
    		String id = request.getParameter("id");
    		String count = request.getParameter("count");
    		Order order = orderService.findOrderById(Integer.parseInt(id));
    		order.setCount(count);
    		int price = Integer.parseInt(count)*Integer.parseInt(order.getSingleprice());
    		order.setPrice(String.valueOf(price));
    		orderService.editOrder(order);
    		//**
    		User user = (User)request.getSession().getAttribute("user");
    		List<Order> list = orderService.getCartList(user.getId());
    		request.setAttribute("list", list);
    		int sumprice = 0;
    		for(int i=0;i<list.size();i++){
    			list.get(i).setUser(userService.findUserById(list.get(i).getUserid()));
    			list.get(i).setProduct(productService.findProductById(list.get(i).getProid()));
    			if(sumprice==0){
    				sumprice = Integer.parseInt(list.get(i).getPrice());
    			}else{
    				sumprice += Integer.parseInt(list.get(i).getPrice());
    			}
    		}
    		request.setAttribute("sumprice", sumprice);
    		request.setAttribute("count", list.size());
    		return new JspView("jsp.cart");
    	}
    	/**
    	 * 
    	 * @param request
    	 * @return
    	 */
    	@At("/deleteorder")
    	public View deleteorder(HttpServletRequest request){
    		String id = request.getParameter("id");
    		orderService.deleteOrder(Integer.parseInt(id));
    		//**
    		User user = (User)request.getSession().getAttribute("user");
    		List<Order> list = orderService.getCartList(user.getId());
    		request.setAttribute("list", list);
    		int sumprice = 0;
    		for(int i=0;i<list.size();i++){
    			list.get(i).setUser(userService.findUserById(list.get(i).getUserid()));
    			list.get(i).setProduct(productService.findProductById(list.get(i).getProid()));
    			if(sumprice==0){
    				sumprice = Integer.parseInt(list.get(i).getPrice());
    			}else{
    				sumprice += Integer.parseInt(list.get(i).getPrice());
    			}
    		}
    		request.setAttribute("sumprice", sumprice);
    		request.setAttribute("count", list.size());
    		return new JspView("jsp.cart");
    	}
    	/**
    	 * 到结算页面
    	 */
    	@At("/tocheckout")
    	public View tocheckout(HttpServletRequest request){
    		String price = request.getParameter("price");
    		request.setAttribute("price", price);
    		return new JspView("jsp.checkout");
    	}
    	/**
    	 * 到付款界面
    	 */
    	@At("/topay")
    	public View topay(HttpServletRequest request){
    		String price = request.getParameter("price");
    		DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); 
    		String tel = request.getParameter("tel");
    		String address = request.getParameter("address");
    		String senddept = request.getParameter("senddept");
    		User user = (User)request.getSession().getAttribute("user");
    		List<Order> list = orderService.getCartList(user.getId());
    		Order order = new Order();
    		for(int i=0;i<list.size();i++){
    			order = list.get(i);
    			order.setAddress(address);
    			order.setDate(df.format(new Date()));
    			order.setSenddept(senddept);
    			order.setTel(tel);
    			orderService.editOrder(order);
    		}
    		request.setAttribute("price", price);
    		return new JspView("jsp.pay");
    	}
    	/**
    	 * 支付
    	 * @param request
    	 * @return
    	 */
    	@At("/pay")
    	public View pay(HttpServletRequest request){
    		User user = (User)request.getSession().getAttribute("user");
    		List<Order> list = orderService.getCartList(user.getId());
    		Order order = new Order();
    		Product product = new Product();
    		for(int i=0;i<list.size();i++){
    			order = list.get(i);
    			order.setSffk(1);
    			order.setVisible(1);
    			orderService.editOrder(order);
    			product = productService.findProductById(order.getProid());
    			if(product.getSfms()==1){//如果是秒杀,秒杀数量-1
    				product.setMscount(product.getMscount()-1);
    				productService.editProduct(product);
    			}
    			
    		}
    		request.setAttribute("msg", "付款成功");
    		//新品上市
    		List<Product> newlist = productService.findNewProduct();
    		request.setAttribute("newlist", newlist);
    		//促销
    		List<Product> cxlist = productService.findCxProduct();
    		request.setAttribute("cxlist", cxlist);
    		return new JspView("jsp.index");
    	}
    	/**
    	 * 
    	 * @param request
    	 * @return
    	 */
    	@At("/toOrderList")
    	public View toOrderList(HttpServletRequest request){
    		User user = (User)request.getSession().getAttribute("user");
    		List<Order> list = orderService.getOrderList(user.getId());
    		for(int i=0;i<list.size();i++){
    			list.get(i).setUser(userService.findUserById(list.get(i).getUserid()));
    			list.get(i).setProduct(productService.findProductById(list.get(i).getProid()));
    		}
    		request.setAttribute("list", list);
    		return new JspView("jsp.orderlist");
    	}
    	
    	@At("/addprice")
    	public View addprice(HttpServletRequest request){
    		User user = (User)request.getSession().getAttribute("user");
    		String addprice = request.getParameter("addprice");
    		//***
    		String id = request.getParameter("id");
    		
    		Product product = productService.findProductById(Integer.parseInt(id));
    		int jpprice = Integer.parseInt(product.getJpprice())+Integer.parseInt(addprice);
    		product.setJpprice(String.valueOf(jpprice));
    		productService.editProduct(product);
    		Order order = new Order();
    		List<Order> listorder = orderService.findOrderByProid(product.getId());
    		if(listorder.size()>0){
    			orderService.deleteOrder(listorder.get(0).getId());
    		}
    		order.setUserid(user.getId());
    		order.setProid(product.getId());
    		order.setCount("1");
    		order.setVisible(0);
    		order.setPrice(String.valueOf(jpprice));
    		orderService.addOrder(order);
    		//促销
    		List<Product> cxlist = productService.findCxProduct();
    		request.setAttribute("cxlist", cxlist);
    		request.setAttribute("product", product);
    		
    		Calendar c =Calendar.getInstance();
    		try{
    		    c.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(product.getJpdate()));
    		}catch (ParseException e) {
    		    e.printStackTrace();
    		}
    		long current_time=System.currentTimeMillis();
    		long end_time=c.getTimeInMillis();
    		long time=end_time-current_time;
    		request.setAttribute("time", time/1000);
    		return new JspView("jsp.jpdetail");
    	}
    	@At("/setVisible")
    	public View setVisible(HttpServletRequest request){
    		String id = request.getParameter("id");
    		User user = (User)request.getSession().getAttribute("user");
    		List<Order> list = orderService.findOrderByProid1(Integer.parseInt(id));
    		if(list.size()>0){
    			Order order = list.get(0);
    			order.setVisible(1);
    			orderService.editOrder(order);
    		}
    		
    		//新品上市
    		List<Product> newlist = productService.findNewProduct();
    		request.setAttribute("newlist", newlist);
    		//促销
    		List<Product> cxlist = productService.findCxProduct();
    		request.setAttribute("cxlist", cxlist);
    		return new JspView("jsp.index");
    	}
    	//houtai****************************************************
    	@At("/htlist")
    	public View htlist(HttpServletRequest request){
    		User user = (User)request.getSession().getAttribute("user");
    		String pagerNum = request.getParameter("pagerNum");
    		if(pagerNum==null){
    			pagerNum = "1";
    		}
    	
    		List<Order> list = orderService.getAllOrderList();
    		request.setAttribute("count", list.size());
    		request.setAttribute("maxPager", PagerUtil.getMaxPager(list.size()));
    		list = (List<Order>) PagerUtil.getPager(list, Integer.parseInt(pagerNum));
    		for(int i=0;i<list.size();i++){
    			list.get(i).setUser(userService.findUserById(list.get(i).getUserid()));
    			list.get(i).setProduct(productService.findProductById(list.get(i).getProid()));
    		}
    		request.setAttribute("list", list);
    		request.setAttribute("pagerNum", pagerNum);
    		return new JspView("jsp.admin.order");
    	}
    	
    }
    
    

    UserAction.java:

    package cn.itbaizhan.action;
    
    import java.util.List;
    
    import javax.servlet.http.HttpServletRequest;
    
    import org.nutz.ioc.loader.annotation.Inject;
    import org.nutz.ioc.loader.annotation.IocBean;
    import org.nutz.mvc.View;
    import org.nutz.mvc.annotation.At;
    import org.nutz.mvc.view.JspView;
    
    import cn.itbaizhan.bean.Product;
    import cn.itbaizhan.bean.User;
    import cn.itbaizhan.service.ProductService;
    import cn.itbaizhan.service.UserService;
    
    @IocBean
    @At("/user")
    public class UserAction {
    	
    	@Inject("refer:userService")
    	private UserService userService;
    	@Inject("refer:productService")
    	private ProductService productService;
    	
    	/**
    	 * 到登录/注册页面
    	 * @param request
    	 * @return
    	 */
    	@At("/tologin")
    	public View tologin(HttpServletRequest request){
    		return new JspView("jsp.login");
    	}
    	/**
    	 * 到注册页面
    	 * @param request
    	 * @return
    	 */
    	@At("/toregister")
    	public View toregister(HttpServletRequest request){
    		return new JspView("jsp.register");
    	}
    	/**
    	 * 注册
    	 * @param request
    	 * @return
    	 */
    	@At("/register")
    	public View register(HttpServletRequest request){
    		String username=request.getParameter("username");
    		String password=request.getParameter("password");
    		String email=request.getParameter("email");
    		User user = new User();
    		user.setUsername(username);
    		user.setPassword(password);
    		user.setEmail(email);
    		user = userService.addUser(user);
    		if(user!=null){
    			request.setAttribute("msg", "success");
    		}else{
    			request.setAttribute("msg", "error");
    		}
    		return new JspView("jsp.register");
    	}
    	
    	
    	/**
    	 * login
    	 */
    	@At("/login")
    	public View login(HttpServletRequest request){
    		String username = request.getParameter("username");
    		String password = request.getParameter("password");
    		List<User> list = userService.findUserByNameAndPsd(username, password);
    		//新品上市
    		List<Product> newlist = productService.findNewProduct();
    		request.setAttribute("newlist", newlist);
    		//促销
    		List<Product> cxlist = productService.findCxProduct();
    		request.setAttribute("cxlist", cxlist);
    		if(list.size()!=1){
    			request.setAttribute("msg", "error");
    			
    			return new JspView("jsp.login");
    		}else{
    			request.setAttribute("user", list.get(0));
    			request.getSession().setAttribute("user", list.get(0));
    			return new JspView("jsp.index");
    		}
    	}
    	/**
    	 * Adminlogin
    	 */
    	@At("/adminlogin")
    	public View adminlogin(HttpServletRequest request){
    		String username = request.getParameter("username");
    		String password = request.getParameter("password");
    		//如果直接请求该方法,就跳转到后台登录页面
    		if(username==null&&password==null){
    			return new JspView("jsp.admin.login");
    		}
    		List<User> list = userService.findUserByNameAndPsd(username, password);
    		if(list.size()!=1){
    			request.setAttribute("msg", "用户名或密码错误");
    			return new JspView("jsp.admin.login");
    		}else{
    			if(list.get(0).getAdmin()==1){
    				request.setAttribute("user", list.get(0));
    				request.getSession().setAttribute("user", list.get(0));
    				return new JspView("jsp.admin.index");
    			}else{
    				request.setAttribute("msg", "无管理员权限");
    				return new JspView("jsp.admin.login");
    			}
    		}
    	}
    	/**
    	 * adminlogout
    	 * @param request
    	 * @return
    	 */
    	@At("/adminlogout")
    	public View adminlogout(HttpServletRequest request){
    		request.getSession().setAttribute("user", null);
    		return new JspView("jsp.admin.login");
    	}
    	/**
    	 * logout
    	 * @param request
    	 * @return
    	 */
    	@At("/logout")
    	public View logout(HttpServletRequest request){
    		request.getSession().setAttribute("user", null);
    		//新品上市
    		List<Product> newlist = productService.findNewProduct();
    		request.setAttribute("newlist", newlist);
    		//促销
    		List<Product> cxlist = productService.findCxProduct();
    		request.setAttribute("cxlist", cxlist);
    		return new JspView("jsp.index");
    	}
    	/**
    	 * 跳转到修改密码
    	 * @param request
    	 * @return
    	 */
    	@At("/tochangePsd")
    	public View tochangePsd(HttpServletRequest request){
    		return new JspView("jsp.changePsd");
    	}
    	/**
    	 * 跳转到admin修改密码
    	 * @param request
    	 * @return
    	 */
    	@At("/toAdminChangePsd")
    	public View toAdminChangePsd(HttpServletRequest request){
    		return new JspView("jsp.admin.changePsd");
    	}
    	/**
    	 * 修改密码
    	 * @param request
    	 * @return
    	 */
    	@At("/changePsd")
    	public View changePsd(HttpServletRequest request){
    		User user = (User)request.getSession().getAttribute("user");
    		String oldpsd = request.getParameter("oldpsd");
    		String newpsd = request.getParameter("newpsd");
    		String cpsd = request.getParameter("cpsd");
    		if(oldpsd.equals(user.getPassword())){
    			if(newpsd.equals(cpsd)){
    				user.setPassword(newpsd);
    				int i = userService.editUser(user);
    				if(i==1){
    					request.setAttribute("msg", "密码修改成功");
    					return new JspView("jsp.changePsd");
    				}else{
    					request.setAttribute("msg", "密码修改失败");
    					return new JspView("jsp.changePsd");
    				}
    				
    			}else{
    				request.setAttribute("msg", "新密码两次输入不一致");
    				return new JspView("jsp.changePsd");
    			}
    			
    		}else{
    			request.setAttribute("msg", "原密码错误");
    			return new JspView("jsp.changePsd");
    		}
    		
    	}
    	/**
    	 * admin修改密码
    	 * @param request
    	 * @return
    	 */
    	@At("/adminChangePsd")
    	public View adminChangePsd(HttpServletRequest request){
    		User user = (User)request.getSession().getAttribute("user");
    		String newpsd = request.getParameter("newpsd");
    		user.setPassword(newpsd);
    		int i = userService.editUser(user);
    		if(i==1){
    			request.setAttribute("msg", "密码修改成功");
    			return new JspView("jsp.admin.changePsd");
    		}else{
    			request.setAttribute("msg", "密码修改失败");
    			return new JspView("jsp.admin.changePsd");
    		}
    	}
    }
    
    

    4、分页辅助类:Page.java

    package cn.itbaizhan.common;
    
    import java.util.List;
    import java.util.Map;
    
    import org.nutz.dao.pager.Pager;
    
    public class Page extends Pager{
    	
    	/**
    	 * 
    	 */
    	private static final long serialVersionUID = 1L;
    	
    	public Page(Pager pager) {
    		setPageNumber(pager.getPageNumber());
    		setPageSize(pager.getPageSize());
    		setRecordCount(pager.getRecordCount());
    	}
    	
    	@SuppressWarnings("rawtypes")
    	private List<Map> list;
    
    	public List<Map> getList() {
    		return list;
    	}
    
    	public void setList(List<Map> list) {
    		this.list = list;
    	}
    	
    	
    }
    
    

    写在最后

    全部源码和详细文档,可加博主V交流:Code2Life2

    展开全文
  • SSM商城后台管理系统源码... 基于ssm,jsp,layui的后台管理系统,mysql数据库。 二、功能介绍 后台登录,用户管理,商品管理,系统设置等。 三、注意事项 1、开发环境为idea,maven,tomcat,数据库为mysql开发。
  • 后台侧栏jsp sideMenu.jsp

    2014-08-31 23:36:08
    &lt;%@ page language="java" import="java.util.*"...http://java.sun.com/jsp/jstl/core" prefix="c"%&gt; &lt;% String path = request.getCont
  • 软件名称:旅游网站和后台管理系统(servlet+jsp) 使用对象:学习或了解过 java 基础课程,开始接触 javaWeb 的学生和软件爱好者 二、 需求分析 该买买买商城的用户包含普通用户和商城管理员。商城设置了权限验证,...
  • 03_后台管理页面/商品列表查询 1.展示后台的首页 1.1 先把前端完成后台管理的页面复制到_web下 把html改为jsp,index.html->jsp 在首行加上page 声明 把文件后缀改为.jsp 1.2 在controller包中新建一个...
  • 后台系统作为管理人员控制web后台的重要手段之一,最主要的功能(相对于较简陋的后台管理系统而言)即是实现与数据库的交互。作为模板的手机商城有一库四表,其中比较重要的是user(用户表)、mobileForm(商品表)...
  • 库存商品管理机试题(JSP)——试题讲解 本试题使用Jsp+Servlet+Mysql+JDBC等技术实现库存商品管理。 语言和环境 A、实现语言 Java B、环境要求 JDK1.8、Eclipse、Tomcat7、JSP、Servlet、Mysql 功能要求 编写一个...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 6,894
精华内容 2,757
关键字:

商品后台管理jsp