基于javaweb的嘟嘟蛋糕商城系统(java+jdbc+servlet+html+ajax+mysql+fileupload)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+jsp的蛋糕商城系统(java+JDBC+Servlet+HTML+Ajax+mysql+Fileupload)
一、项目运行 环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
Jdbc+ Servlert + html+ css + JavaScript + JQuery + Ajax + Fileupload等等
用户登录控制层:
@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”, “用户名、邮箱或者密码错误,请重新登录!”);
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 {
订单提交控制层:
@WebServlet(name = “order_submit”,urlPatterns = “/order_submit”)
public class OrderSubmitServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if(request.getSession().getAttribute(“user”)!=null) {
request.getRequestDispatcher(“/order_submit.jsp”).forward(request, response);
}else {
request.setAttribute(“failMsg”, “请登录后,再提交订单!”);
request.getRequestDispatcher(“/user_login.jsp”).forward(request, response);
后台管理员控制层:
@WebServlet(name = “admin_user_list”,urlPatterns = “/admin/user_list”)
public class AdminUserListServlet extends HttpServlet {
private UserService uService = new UserService();
/**
- @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
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 = uService.getUserPage(pageNumber);
if(p.getTotalPage()==0)
p.setTotalPage(1);
p.setPageNumber(1);
else {
if(pageNumber>=p.getTotalPage()+1)
p = uService.getUserPage(pageNumber);
request.setAttribute(“p”, p);
request.getRequestDispatcher(“/admin/user_list.jsp”).forward(request, response);
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
this.doGet(req, resp);
后台管理商品控制层:
@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;//推荐类型
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);