brand.jsp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  2. <%@ page contentType="text/html; utf-8" pageEncoding="UTF-8" %>
  3. <!DOCTYPE html>
  4. <html lang="en">
  5. <head>
  6. <meta charset="UTF-8">
  7. <title>Title</title>
  8. </head>
  9. <body>
  10. <h1> ${sessionScope.user.username} 欢迎您</h1>
  11. <input style="width: 100px" type="button" value="新增" id="addbrand" ><br>
  12. <hr />
  13. <jsp:useBean id="MyBrand" class="com.lovecoding.study.domian.Brand" scope="page" ></jsp:useBean>
  14. <jsp:setProperty name="MyBrand" property="brandName" value="达利园" />
  15. <jsp:setProperty name="MyBrand" property="companyName" value="达利园食品有限公司" />
  16. <%--<jsp:getProperty name="MyBrand" property="brandName"/> <br />--%>
  17. <%--<%=MyBrand.getBrandName()%> <br />--%>
  18. 可以解析: ${MyBrand.brandName} <br />
  19. 可以解析: ${MyBrand["brandName"]} <br />
  20. 不正确: ${MyBrand[brandName]} <br />
  21. <hr />
  22. <table border="1" cellspacing="0" width="80%">
  23. <tr>
  24. <th>序号</th>
  25. <th>品牌名称</th>
  26. <th>企业名称</th>
  27. <th>排序</th>
  28. <th>品牌介绍</th>
  29. <th>状态</th>
  30. <th>操作</th>
  31. </tr>
  32. <%-- items 我们要循环的数据源 var 是我们循环得到临时数据变量 --%>
  33. <c:forEach items="${requestScope.brands}" var="brand" >
  34. <tr>
  35. <th>${brand.id}</th>
  36. <th>${brand.brandName}</th>
  37. <th>${brand.companyName}</th>
  38. <th>${brand.ordered}</th>
  39. <th>${brand.description}</th>
  40. <th>
  41. <c:if test="${brand.status == 1}">
  42. 启动
  43. </c:if>
  44. <c:if test="${brand.status != 1}">
  45. 禁用
  46. </c:if>
  47. </th>
  48. <th>
  49. <a href="${pageContext.servletContext.contextPath}/updateBrand?id=${brand.id}" > 修改 </a>
  50. <a href="${pageContext.servletContext.contextPath}/deleteBrand?id=${brand.id}" > 删除 </a>
  51. </th>
  52. </tr>
  53. </c:forEach>
  54. </table>
  55. <script>
  56. document.getElementById("addbrand").onclick = function(){
  57. location.href="<%=request.getContextPath()%>/addBrand.jsp"
  58. }
  59. </script>
  60. </body>
  61. </html>