Source code acquisition : Blog home page " resources " Download in !

one , Project brief

function : Classified display of goods , User registration login , Shopping Cart , Order settlement , Shopping cart addition and subtraction , Back office commodity management , Classified management , Order management and so on can .

two , Project operation

Environment configuration : Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ
IDEA,Eclispe,MyEclispe,Sts All support )

Project technology : Jdbc+ Servlert + Jsp + css + JavaScript + JQuery + Ajax + Fileupload wait .

User registration control layer :
@WebServlet(name = "user_register",urlPatterns = "/user_rigister") public
class UserRegisterServlet extends HttpServlet { private UserService uService =
new UserService(); protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException { User user
= new User(); try { BeanUtils.copyProperties(user, request.getParameterMap());
} catch (IllegalAccessException e) { // TODO Auto-generated catch block
e.printStackTrace(); } catch (InvocationTargetException e) { // TODO
Auto-generated catch block e.printStackTrace(); } if(uService.register(user)) {
request.setAttribute("msg", " login was successful , Please login !");
request.getRequestDispatcher("user_login.jsp").forward(request, response);
}else { request.setAttribute("msg", " Duplicate user name or mailbox , Please fill in again !");
request.getRequestDispatcher("user_register.jsp").forward(request, response); }
} protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException { } }

User login control layer :
@WebServlet(name = "user_login",urlPatterns = "/user_login") public class
UserLoginServlet extends HttpServlet { private UserService uService = new
UserService(); protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException { String ue
= request.getParameter("ue"); String password =
request.getParameter("password"); User user = uService.login(ue, password);
if(user==null) { request.setAttribute("failMsg", " user name , Email or password error , Please login again !");
request.getRequestDispatcher("/user_login.jsp").forward(request, response);
}else { request.getSession().setAttribute("user", user);
request.getRequestDispatcher("/user_center.jsp").forward(request, response); }
} protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException { } }

Commodity detail control layer :
@WebServlet(name = "goods_detail",urlPatterns = "/goods_detail") public class
GoodsDetailServlet extends HttpServlet { private GoodsService gService = new
GoodsService(); protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException { }
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { int id =
Integer.parseInt(request.getParameter("id")); Goods g =
gService.getGoodsById(id); request.setAttribute("g", g);
request.getRequestDispatcher("/goods_detail.jsp").forward(request, response); }
}

Order control layer :
@WebServlet(name = "admin_order_list",urlPatterns = "/admin/order_list")
public class AdminOrderListServlet extends HttpServlet { private OrderService
oService = new OrderService(); /** * @see HttpServlet#doGet(HttpServletRequest
request, HttpServletResponse response) */ protected void
doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException { int status = 0;
if(request.getParameter("status") != null) {
status=Integer.parseInt(request.getParameter("status") ) ; }
request.setAttribute("status", status); int pageNumber = 1;
if(request.getParameter("pageNumber") != null) { try {
pageNumber=Integer.parseInt(request.getParameter("pageNumber") ) ; } catch
(Exception e) { } } if(pageNumber<=0) pageNumber=1; Page p =
oService.getOrderPage(status,pageNumber); if(p.getTotalPage()==0) {
p.setTotalPage(1); p.setPageNumber(1); } else {
if(pageNumber>=p.getTotalPage()+1) { p =
oService.getOrderPage(status,pageNumber); } } request.setAttribute("p", p);
request.getRequestDispatcher("/admin/order_list.jsp").forward(request,
response); } }

Administrator commodity control layer :
@WebServlet(name = "admin_goods_list",urlPatterns = "/admin/goods_list")
public class AdminGoodsListServlet extends HttpServlet { private GoodsService
gService = new GoodsService(); /** * @see HttpServlet#doGet(HttpServletRequest
request, HttpServletResponse response) */ protected void
doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException { int type = 0;// Recommended type
if(request.getParameter("type") != null) {
type=Integer.parseInt(request.getParameter("type") ) ; } int pageNumber = 1;
if(request.getParameter("pageNumber") != null) { try {
pageNumber=Integer.parseInt(request.getParameter("pageNumber") ) ; } catch
(Exception e) { } } if(pageNumber<=0) pageNumber=1; Page p =
gService.getGoodsRecommendPage(type, pageNumber); if(p.getTotalPage()==0) {
p.setTotalPage(1); p.setPageNumber(1); } else {
if(pageNumber>=p.getTotalPage()+1) { p = gService.getGoodsRecommendPage(type,
pageNumber); } } request.setAttribute("p", p); request.setAttribute("type",
type); request.getRequestDispatcher("/admin/goods_list.jsp").forward(request,
response); } /** * @see HttpServlet#doPost(HttpServletRequest request,
HttpServletResponse response) */ protected void doPost(HttpServletRequest
request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub doGet(request, response); } }
Source code acquisition : Blog home page " resources " Download in ! 

Technology