5.文件夹管理

1.分页查询

1.修改FolderMapper
SpringMVC-14-(文档管理系统---文件夹管理)
2.修改FolderMapper.xml
SpringMVC-14-(文档管理系统---文件夹管理)
3.创建FolderVo
SpringMVC-14-(文档管理系统---文件夹管理)
4.创建PageBean

public class PageBean {

	private Integer currentPage=1;
	private Integer pageSize=5;
	private Integer totalPage;
	private Long totalCount;
	
	public Integer getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(Integer currentPage) {
		this.currentPage = currentPage;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(Integer totalPage) {
		this.totalPage = totalPage;
	}

	public Long getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(Long totalCount) {
		this.totalCount = totalCount;
		this.totalPage=(int) Math.ceil(this.totalCount*1.0/this.pageSize);
	}
	
	
	
}

5.创建FolderService

SpringMVC-14-(文档管理系统---文件夹管理)
6.创建FolderServiceImpl
SpringMVC-14-(文档管理系统---文件夹管理)
7.创建FolderController
SpringMVC-14-(文档管理系统---文件夹管理)
8.创建WEB-INF/view/folder/list.jsp
SpringMVC-14-(文档管理系统---文件夹管理)

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="${ctx }/resources/css/pintuer.css">
<link rel="stylesheet" href="${ctx }/resources/css/admin.css">
<script src="${ctx }/resources/js/jquery.js"></script>
<script src="${ctx }/resources/js/pintuer.js"></script>
</head>
<body>
	<form method="post" action="" id="listform">
		<div class="panel admin-panel">
			<div class="panel-head">
				<strong class="icon-reorder"> 内容列表</strong> <a href=""
					style="float:right; display:none;">添加字段</a>
			</div>
			<div class="padding border-bottom">
				<ul class="search" style="padding-left:10px;">
					<li><a class="button border-main icon-plus-square-o"
						href="add.html"> 添加文件夹</a></li>
					<li><input type="text" placeholder="请输入搜索关键字"
					 value="${folderVo.tname }" name="tname" id="tname"
						class="input"
						style="width:250px; line-height:17px;display:inline-block" /> <a
						href="javascript:void(0)" class="button border-main icon-search"
						onclick="changesearch()"> 搜索</a></li>
				</ul>
			</div>
			<table class="table table-hover text-center">
				<tr>
					<th width="10%">编号</th>
					<th>文件夹名</th>
					<th>备注</th>
					<th width="310">操作</th>
				</tr>
				<c:forEach items="${list }" var="sn">
					<tr>
						<td>${sn.tid }</td>
						<td><font color="#00CC99">${sn.tname }</font></td>
						<td>${sn.tremark }</td>
						<td><div class="button-group">
								<a class="button border-main" href="update.html"><span
									
									class="icon-edit"></span> 修改</a>
									 <a class="button border-red"
									href="javascript:void(0)" onclick="return del(1,1,1)">
									<span
									class="icon-trash-o"></span> 删除</a>
							</div></td>
					</tr>
				</c:forEach>
				<tr>
					<td colspan="8"><div class="pagelist">
							<c:choose>
								<c:when test="${page.currentPage>1 }">
									<a href="javascript:void(0);" 
									onclick="changePage(${page.currentPage-1})">上一页</a> 
								</c:when>
								<c:otherwise>
									<a href="javascript:void(0);" 
									style="cursor: default;">上一页</a> 
								</c:otherwise>
							</c:choose>
							
							<c:forEach begin="1" end="${page.totalPage }" var="sn">
								<c:choose>
									<c:when test="${sn==page.currentPage }">
										<span class="current">${sn }</span>
									</c:when>
									<c:otherwise>
										<a href="javascript:void(0);" onclick="changePage(${sn 
										})">${sn }</a>
									</c:otherwise>
								</c:choose>
							</c:forEach>
							
							<c:choose>
								<c:when test="${page.currentPage<page.totalPage }">
									<a href="javascript:void(0);" 
									onclick="changePage(${page.currentPage+1})">下一页</a>
									<a href="javascript:void(0);" 
									onclick="changePage(${page.totalPage})">尾页</a>
								</c:when>
								<c:otherwise>
									<a href="javascript:void(0);" style="cursor: default;">下一页</a>
									<a href="javascript:void(0);" style="cursor: default;">尾页</a>
								</c:otherwise>
							</c:choose>
						</div></td>
				</tr>
			</table>
		</div>
	</form>
	<script type="text/javascript">
		//搜索
		function changesearch() {
			changePage(1);
		}
		//分页
		function changePage(pageNum) {
			var tname=$("#tname").val();
			window.location.href="${ctx}/folder/loadAllFolder.action?
			tname="+tname+"&currentPage="+pageNum;
		}

		//单个删除
		function del(id, mid, iscid) {
			if (confirm("您确定要删除吗?")) {

			}
		}
	</script>
</body>
</html>

2.添加修改删除

1.修改FolderController

/**
	 * 跳转到添加页面
	 */
	@RequestMapping("toAddFolder")
	public String toAddFolder(){
		return "folder/add";
	}
	
	/**
	 * 添加
	 */
	@RequestMapping("addFolder")
	public String toAddFolder(FolderVo folderVo,HttpSession session){
		User user=(User) session.getAttribute("user");
		folderVo.setUid(user.getUid());
		this.folderService.addFolder(folderVo);
		return "redirect:loadAllFolder.action";
	}
	
	/**
	 * 跳转到修改页面
	 */
	@RequestMapping("toUpdateFolder")
	public String toUpdateFolder(FolderVo folderVo){
		Folder folder=this.folderService.queryFolderById(folderVo.getTid());
		BeanUtils.copyProperties(folder, folderVo);
		return "folder/update";
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("updateFolder")
	public String updateFolder(FolderVo folderVo){
		this.folderService.updateFolder(folderVo);
		return "redirect:loadAllFolder.action";
	}
	/**
	 * 删除
	 */
	@RequestMapping("deleteFolder")
	public String deleteFolder(FolderVo folderVo){
		this.folderService.deleteFolder(folderVo.getTid());
		return "redirect:loadAllFolder.action";
	}

2.修改FolderService
SpringMVC-14-(文档管理系统---文件夹管理)
3.修改FolderServiceImpl
SpringMVC-14-(文档管理系统---文件夹管理)
4.修改WEB-INF/view/folder/list.jsp
SpringMVC-14-(文档管理系统---文件夹管理)
SpringMVC-14-(文档管理系统---文件夹管理)
SpringMVC-14-(文档管理系统---文件夹管理)
5.创建WEB-INF/view/folder/add.jsp
SpringMVC-14-(文档管理系统---文件夹管理)
6.创建WEB-INF/view/folder/update.jsp
SpringMVC-14-(文档管理系统---文件夹管理)

相关文章:

  • 2021-12-15
猜你喜欢
  • 2022-01-08
  • 2021-12-26
  • 2021-10-26
  • 2021-04-26
相关资源
相似解决方案