标签:val close attribute 提交 res enc css content 支付
案例1-分类信息的curd 步骤分析: 左边的dtree: 1.导入dtree.js 2.导入dtree.css 3.创建一个div 添加样式 class="dtree" 4.在div中编写js代码 创建一个树 d = new dTree(‘d‘); 添加根节点 通过 d.add(当前节点的id,父节点的id,显示的名称,点击时候打开的连接,放上去显示的名称,在那个地方打开这个连接) 注意: 根节点的父节点的id写成-1 添加其他节点 5.最后通过document.write(d) 写到页面上即可 分类信息添加: 1.应在在左边的dtree上添加连接(展示所有的分类信息) d.add(...,"/store/adminCategory?method=findAll","","mainFrame") 2.创建adminCategoryservlet ,编写findAll() 查询的结果是一个list,将list放入request域中,然后请求转发/admin/category/list.jsp 添加分类的步骤: 1.编写一个连接, /store/adminCategory?method=addUI 2.请求转发到/admin/category/add.jsp 3.add.jsp就是一个表单页面 编写表单的action属性 /store/adminCategory?method=add 给分类的名称字段添加一个name属性 name="cname" 4.admincategoryservlet的add方法 获取分类的名称 封装成category 设置id 调用categoryservice的add方法 页面重定向 /store/adminCategory?method=findAll 5.categoryservice的add方法 暂时调用dao 6.dao中添加一条数据 修改分类步骤分析: 1.在list.jsp页面上点击修改(编辑) /store/adminCategory?method=getById&cid=??? 2.在getById方法中 获取cid 调用service 通过id获取一个分类, 将category放入request域中 请求转发 edit.jsp 3.eidt页面是一个表单 添加action属性 /store/adminCategory?method=update 修改内容 点击提交 添加隐藏域 cid 4.在update方法中 获取cid和cname 封装成category 调用service的update方法 重定向/store/adminCategory?method=findAll 5.在service的update方法中 调用dao更新 清空缓存 6.dao中更新数据 删除分类步骤分析: 1.在list.jsp上编写 删除连接 /store/adminCategory?method=delete&cid=?? 2.在delete方法中 获取cid 调用service的delete方法 页面重定向/store/adminCategory?method=findAll 3.service中delete 添加事务 通过cid先更新所有的商品分类信息 调用dao 删除分类 事务控制 清空缓存
<%@ page language="java" pageEncoding="UTF-8"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>菜单</title> <link href="${pageContext.request.contextPath}/css/left.css" rel="stylesheet" type="text/css"/> <link rel="StyleSheet" href="${pageContext.request.contextPath}/css/dtree.css" type="text/css" /> </head> <body> <table width="100" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="12"></td> </tr> </table> <table width="100%" border="0"> <tr> <td> <div class="dtree"> <a href="javascript: d.openAll();">展开所有</a> | <a href="javascript: d.closeAll();">关闭所有</a> <script type="text/javascript" src="${pageContext.request.contextPath}/js/dtree.js"></script> <script type="text/javascript"> d = new dTree(‘d‘); d.add(‘01‘,-1,‘系统菜单树‘); d.add(‘0102‘,‘01‘,‘分类管理‘,‘‘,‘‘,‘mainFrame‘); d.add(‘010201‘,‘0102‘,‘展示所有‘,‘${pageContext.request.contextPath}/adminCategory?method=findAll‘,‘‘,‘mainFrame‘); d.add(‘010202‘,‘0102‘,‘添加分类‘,‘${pageContext.request.contextPath}/adminCategory?method=addUI‘,‘‘,‘mainFrame‘); d.add(‘0104‘,‘01‘,‘商品管理‘); d.add(‘010401‘,‘0104‘,‘商品管理‘,‘${pageContext.request.contextPath}/adminProduct?method=findAll‘,‘‘,‘mainFrame‘); d.add(‘0105‘,‘01‘,‘订单管理‘); d.add(‘010501‘,‘0105‘,‘所有订单‘,‘${pageContext.request.contextPath}/adminOrder?method=findAllByState‘,‘‘,‘mainFrame‘); d.add(‘010502‘,‘0105‘,‘未支付订单‘,‘${pageContext.request.contextPath}/adminOrder?method=findAllByState&state=0‘,‘‘,‘mainFrame‘); d.add(‘010503‘,‘0105‘,‘已支付订单‘,‘${pageContext.request.contextPath}/adminOrder?method=findAllByState&state=1‘,‘‘,‘mainFrame‘); d.add(‘010504‘,‘0105‘,‘已发货订单‘,‘${pageContext.request.contextPath}/adminOrder?method=findAllByState&state=2‘,‘‘,‘mainFrame‘); d.add(‘010505‘,‘0105‘,‘已完成订单‘,‘${pageContext.request.contextPath}/adminOrder?method=findAllByState&state=3‘,‘‘,‘mainFrame‘); document.write(d); </script> </div> </td> </tr> </table> </body> </html>
<servlet> <description></description> <display-name>AdminCategoryServlet</display-name> <servlet-name>AdminCategoryServlet</servlet-name> <servlet-class>com.louis.web.servlet.AdminCategoryServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>AdminCategoryServlet</servlet-name> <url-pattern>/adminCategory</url-pattern> </servlet-mapping>
public String findAll(HttpServletRequest request, HttpServletResponse response) throws Exception { //1.调用categoryservice 查询所有的分类信息 返回值 list CategoryService cs=(CategoryService) BeanFactory.getBean("CategoryService"); List<Category> list = cs.findAll(); //2.将list放入request域中 请求转发即可 request.setAttribute("list", list); return "/admin/category/list.jsp"; }
<%@ page language="java" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <HTML> <HEAD> <meta http-equiv="Content-Language" content="zh-cn"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link href="${pageContext.request.contextPath}/css/Style1.css" rel="stylesheet" type="text/css" /> <script language="javascript" src="${pageContext.request.contextPath}/js/public.js"></script> <script type="text/javascript"> function addCategory(){ window.location.href = "${pageContext.request.contextPath}/adminCategory?method=addUI"; } </script> </HEAD> <body> <br> <table cellSpacing="1" cellPadding="0" width="100%" align="center" bgColor="#f5fafe" border="0"> <TBODY> <tr> <td class="ta_01" align="center" bgColor="#afd1f3"> <strong>分类列表</strong> </TD> </tr> <tr> <td class="ta_01" align="right"> <button type="button" id="add" name="add" value="添加" class="button_add" onclick="addCategory()"> 添加分类 </button> </td> </tr> <tr> <td class="ta_01" align="center" bgColor="#f5fafe"> <table cellspacing="0" cellpadding="1" rules="all" bordercolor="gray" border="1" id="DataGrid1" style="BORDER-RIGHT: gray 1px solid; BORDER-TOP: gray 1px solid; BORDER-LEFT: gray 1px solid; WIDTH: 100%; WORD-BREAK: break-all; BORDER-BOTTOM: gray 1px solid; BORDER-COLLAPSE: collapse; BACKGROUND-COLOR: #f5fafe; WORD-WRAP: break-word"> <tr style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; HEIGHT: 25px; BACKGROUND-COLOR: #afd1f3"> <td align="center" width="18%"> 序号 </td> <td align="center" width="17%"> 分类名称 </td> <td width="7%" align="center"> 编辑 </td> <td width="7%" align="center"> 删除 </td> </tr> <c:forEach var="c" items="${ list }" varStatus="vs"> <tr onmouseover="this.style.backgroundColor = ‘white‘" onmouseout="this.style.backgroundColor = ‘#F5FAFE‘;"> <td style="CURSOR: hand; HEIGHT: 22px" align="center" width="18%"> ${vs.count } </td> <td style="CURSOR: hand; HEIGHT: 22px" align="center" width="17%"> ${c.cname } </td> <td align="center" style="HEIGHT: 22px"> <a href="${ pageContext.request.contextPath }/adminCategory?method=getById&cid=${c.cid}"> <img src="${pageContext.request.contextPath}/images/i_edit.gif" border="0" style="CURSOR: hand"> </a> </td> <td align="center" style="HEIGHT: 22px"> <a href="javascript:void(0)" onclick="deleteC(‘${c.cid}‘)"> <img src="${pageContext.request.contextPath}/images/i_del.gif" width="16" height="16" border="0" style="CURSOR: hand"> </a> </td> </tr> </c:forEach> </table> </td> </tr> </TBODY> </table> </body> <script type="text/javascript"> function deleteC(cid){ if(confirm("您确定要删除该分类吗?")){ location.href="${ pageContext.request.contextPath }/adminCategory?method=delete&cid="+cid; } } </script> </HTML>
1、varstatus items 计数 12天的教程
标签:val close attribute 提交 res enc css content 支付
原文地址:http://www.cnblogs.com/Michael2397/p/7672676.html