首页 > 其他分享 >后台servlet OrderListSer

后台servlet OrderListSer

时间:2023-04-26 15:33:22浏览次数:40  
标签:pageIndex substance end OrderListSer request 后台 import null servlet


package cn.service.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.entity.OrderFather;
import cn.entity.OrderFatherStatus;
import cn.service.biz.OrderFatherBiz;
import cn.service.biz.impl.OrderFatherBizImpl;
import cn.service.dao.NeOrderFatherDao;
import cn.service.dao.OrderFatherStatusDao;
import cn.service.dao.impl.NeOrderFatherDaoImpl;
import cn.service.dao.impl.OrderFatherStatusDaoImpl;
import cn.service.tool.Tool;

public class OrderListSer extends HttpServlet {
	public OrderListSer() {
		super();
	}
	public void destroy() {
		super.destroy(); 
	}
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		//接收时设置的编码  
		request.setCharacterEncoding("utf-8");  
		//转发时设置的编码  
		response.setCharacterEncoding("utf-8");  
		//以 超文本格式 方式转发  
		response.setContentType("text/html");  
		//获取了一个输出流  
		PrintWriter out = response.getWriter(); 
		
		//分页查询,联表(订单主表,订单子表,订单状态表,商品表)
		OrderFatherBiz orderFatherBiz = new OrderFatherBizImpl();
		NeOrderFatherDao neOrderFatherDao = new NeOrderFatherDaoImpl();
		List<OrderFather> ofList = null;
		String substance = request.getParameter("substance");  
		String pageIndexStr = request.getParameter("pageIndex");
		int pageIndex = pageIndexStr !=null ? Integer.parseInt(pageIndexStr) : 1;
		int totalCount = 0;
		int  end =0;
		if(substance==null){
			totalCount = neOrderFatherDao.getTotalCount(null, null);
			end = (int)Math.ceil((double)totalCount/Tool.pageSize);
			if(pageIndex < 1){
				ofList =orderFatherBiz.getOrderFatherByPage(1, Tool.pageSize, null, null);
			}else if(pageIndex > end){ 
				pageIndex = end;
				ofList =orderFatherBiz.getOrderFatherByPage(end, Tool.pageSize, null, null);
			}else{
				ofList =orderFatherBiz.getOrderFatherByPage(pageIndex, Tool.pageSize, null, null);
			}
		}else if(neOrderFatherDao.getTotalCount(substance, null)>0){
			totalCount = neOrderFatherDao.getTotalCount(substance, null);
			end = (int)Math.ceil((double)totalCount/Tool.pageSize);
			if(pageIndex < 1){
				ofList =orderFatherBiz.getOrderFatherByPage(1, Tool.pageSize, substance, null);
			}else if(pageIndex > end){ 
				pageIndex = end;
				ofList =orderFatherBiz.getOrderFatherByPage(end, Tool.pageSize, substance, null);
			}else{
				ofList =orderFatherBiz.getOrderFatherByPage(pageIndex, Tool.pageSize, substance, null);
			}

		}else{
			totalCount = neOrderFatherDao.getTotalCount(null, substance);
			end = (int)Math.ceil((double)totalCount/Tool.pageSize);
			if(pageIndex < 1){
				ofList =orderFatherBiz.getOrderFatherByPage(1,  Tool.pageSize, null, substance);
			}else if(pageIndex > end){ 
				pageIndex = end;
				ofList =orderFatherBiz.getOrderFatherByPage(end, Tool.pageSize, null, substance);
			}else{
				ofList =orderFatherBiz.getOrderFatherByPage(pageIndex, Tool.pageSize, null, substance);
			}
		}

		request.setAttribute("substance",substance);
		request.setAttribute("totalCount",totalCount);
		request.setAttribute("end",end);
		request.setAttribute("pageIndex",pageIndex);
		request.setAttribute("ofList",ofList);
		
		//订单状态下拉菜单
		OrderFatherStatusDao orderFatherStatusDao = new OrderFatherStatusDaoImpl();
		List<OrderFatherStatus> ofsList = orderFatherStatusDao.orderFatherStatusList();
		request.setAttribute("ofsList",ofsList);

		request.getRequestDispatcher("admin/orderList.jsp").forward(request, response);
		out.flush();
		out.close();
	}
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}
	public void init() throws ServletException {
	}
}

 

标签:pageIndex,substance,end,OrderListSer,request,后台,import,null,servlet
From: https://blog.51cto.com/u_16089934/6228045

相关文章

  • 后台servlet LoginOfAdminSer
    packagecn.service.servlet;importjava.io.IOException;importjava.io.PrintWriter;importjavax.servlet.ServletException;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse......
  • 后台servlet SideMenuSer
    packagecn.service.servlet;importjava.io.IOException;importjava.io.PrintWriter;importjavax.servlet.ServletException;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse......
  • Springboot 在linux后台运行的方法
    1、后台运行程序nohupjava-jar自己的springboot项目.jar>日志文件名.log2>&1&命令详解:nohup:不挂断地运行命令,退出帐户之后继续运行相应的进程。>日志文件名.log:是nohup把command的输出重定向到当前目录的指定的“日志文件名.log”文件中,即输出内容不打印到屏幕上,而......
  • Servlet添加自定义的过滤器没有效果?
    在学习HttpServlet的时候有个自定义过滤器的定义类,我们想让特定url走过滤器。publicclassMyFilterimplementsFilter{privateFilterConfigconfig;publicvoidinit(FilterConfigconfig)throwsServletException{this.config=config;}publi......
  • React、Ant Design 5.0 构建通用后台管理系统 - 接口服务环境搭建
    目录项目初始化项目结构package.jsontsconfig.jsonnodemon.jsonindex.tssrc/server.ts运行项目初始化mkdirgeneral-admin-system-servercdgeneral-admin-system-servernpminit-ynpminstalltypescriptts-node@types/nodenodemon@swc/core@swc/helpersregenerator-......
  • 2种方法将exe注册为windows服务,直接从后台运行
    方法1sc命令行创建命令行创建这个方法我遇到了下面的问题,按照网上的方式没有解决,有解决的朋友@一下方法2使用instsrv+srvany什么是instsrv+srvanyinstsrv.exe.exe和srvany.exe是MicrosoftWindowsResourceKits工具集中的两个实用工具,这两个工具配合使用可以将任何的ex......
  • React、Ant Design 5.0 构建通用后台管理系统 - 登录页面
    目录安装依赖main.tsxsrc/styles/global.cssApp.tsxsrc/pages/user/Login/index.tsxsrc/pages/user/Login/style.module.css安装依赖npminstallantd@ant-design/icons@ant-design/pro-componentsAntDesign组件库@ant-design/pro-components封装一些好用的常用组件库mai......
  • 预防数据后台管理的开发
    预防数据后台管理页面在若依自带的组件中是没有上传的组件,我到element中找了对应的组件 通过将其中的代码复制到vue相应的位置,页面中就也显示出这个模型,其中那些中文字,我们可以进行修改。接口的调用就是比较的简单了,直接将上传视频的接口复制到action中去就可以成功的运行起......
  • request getContextPath() getServletPath()[转的]
    项目名zhangyulonghttp://localhost:8080/zhangyulong/main/index.jsprequest.getContextPath()得到:/zhangyulongrequest.getServletPath()得到:/main/index.jsprequest.getRequestURI()得到:/zhangyulong/main/index.jsprequest.getRealPath("/")得到:F:......
  • Servlet技术
    Servlet(ServerApplet)是Java Servlet的简称,称为小服务程序或服务连接器,用Java编写的服务器端程序,具有独立于平台和协议的特性,主要功能在于交互式地浏览和生成数据,生成动态Web内容。Servlet的生命周期Servlet生命周期可被定义为从创建直到毁灭的整个过程。三个步骤即:初始化---......