• 大小: 701KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-28
  • 语言: Java
  • 标签: java  jsp  

资源简介

初学者尝试写的一个jdbc+mysql+jsp实现的简单管理系统,包含数据的增删改查分页等功能。

资源截图

代码片段和文件信息

package com.zzrd.commoditySystem.commodity.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

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

import com.zzrd.commoditySystem.commodity.service.CommodityService;
import com.zzrd.commoditySystem.util.ConstVar;


/**
 * Servlet implementation class CommodityCotroller
 */
@WebServlet(name = “Commodity“ urlPatterns = { “/Commodity“ })
public class CommodityCotroller extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
 * @see HttpServlet#service(HttpServletRequest request HttpServletResponse response)
 */
protected void service(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {
request.setCharacterEncoding(“utf-8“);
String flag = request.getParameter(“type“);
if(flag.equals(“addpage“)) { //添加
addCommodity(requestresponse);
}else if(flag.equals(“save“)) { //保存
saveCommodity(requestresponse);
}else if(flag.equals(“findone“)) { // 查询修改
findone(requestresponse);
}else if(flag.equals(“update“)) { //更新操作
update(requestresponse);
}else if(flag.equals(“delete“)) { //删除
delete(requestresponse);
}else if(flag.equals(“selectPage“)) { // 分页
selectPage(requestresponse);
}
}

private void selectPage(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {
request.setCharacterEncoding(“utf-8“);
String pageIndex = request.getParameter(“pageIndex“) == null ? ConstVar.DEFAULT_PAGEINDEX : request.getParameter(“pageIndex“);
String pageNo = request.getParameter(“pageNo“) == null ? ConstVar.DEFAULT_PAGENO : request.getParameter(“pageNo“);
String search = request.getParameter(“searchText“);
if(search != null && “get“.equals(request.getMethod().toLowerCase())) {
search = new String(search.getBytes(“iso-8859-1“)“utf-8“);
}
Listject>> list = new ArrayListject>>();
CommodityService ss = new CommodityService();
list = ss.showListPage(pageIndexpageNosearch);
int totalNo = ss.showListPageCount(search);
request.setAttribute(“pageIndex“ pageIndex);//当前页
request.setAttribute(“pageNo“ pageNo);//每页几条
request.setAttribute(“totalNo“ totalNo);//总条数
request.setAttribute(“totalPage“ Math.ceil(totalNo / Double.valueOf(pageNo)));//总页数
request.setAttribute(“commodityinfo“ list);
request.setAttribute(“search“ search);
request.getRequestDispatcher(“view/commodity/showList.jsp“).forward(request response);

}

private void delete(HttpServletRequest request HttpServletResponse response) throws ServletExceptionIOException {
String id =request.getParameter(“id“);
CommodityService ss = new CommodityService();
ss.de

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-02-12 10:47  exam\
     文件         841  2019-01-11 09:40  exam\.classpath
     文件         904  2019-01-11 09:40  exam\.project
     目录           0  2019-02-12 10:47  exam\.settings\
     文件         567  2019-01-11 09:40  exam\.settings\.jsdtscope
     文件         364  2019-01-11 09:40  exam\.settings\org.eclipse.jdt.core.prefs
     文件         464  2019-01-11 09:40  exam\.settings\org.eclipse.wst.common.component
     文件         345  2019-01-11 09:40  exam\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2019-01-11 09:40  exam\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2019-01-11 09:40  exam\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2019-02-12 10:47  exam\WebContent\
     目录           0  2019-02-12 10:47  exam\WebContent\meta-INF\
     文件          39  2019-01-11 09:40  exam\WebContent\meta-INF\MANIFEST.MF
     目录           0  2019-02-12 10:47  exam\WebContent\WEB-INF\
     目录           0  2019-02-12 10:47  exam\WebContent\WEB-INF\lib\
     文件      703265  2019-01-04 12:44  exam\WebContent\WEB-INF\lib\mysql-connector-java-5.1.6.jar
     目录           0  2019-02-12 10:47  exam\WebContent\view\
     目录           0  2019-02-12 10:47  exam\WebContent\view\commodity\
     文件        2681  2019-01-11 11:51  exam\WebContent\view\commodity\add.jsp
     文件        3710  2019-01-11 14:30  exam\WebContent\view\commodity\findone.jsp
     文件        4011  2019-01-11 14:33  exam\WebContent\view\commodity\showList.jsp
     目录           0  2019-02-12 10:47  exam\WebContent\view\famework\
     文件         896  2019-01-11 09:54  exam\WebContent\view\famework\left.jsp
     文件         501  2019-01-04 16:05  exam\WebContent\view\famework\main.jsp
     文件         376  2019-01-11 09:54  exam\WebContent\view\famework\right.jsp
     文件         525  2019-01-11 09:55  exam\WebContent\view\famework\top.jsp
     目录           0  2019-02-12 10:47  exam\WebContent\view\farm\
     文件        1745  2019-01-11 14:33  exam\WebContent\view\farm\add.jsp
     文件        2408  2019-01-11 14:30  exam\WebContent\view\farm\findone.jsp
     文件        3707  2019-01-11 13:04  exam\WebContent\view\farm\showList.jsp
     目录           0  2019-02-12 10:47  exam\build\
............此处省略42个文件信息

评论

共有 条评论