12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
- <%@ page contentType="text/html; utf-8" pageEncoding="UTF-8" %>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- </head>
- <body>
- <h1> ${sessionScope.user.username} 欢迎您</h1>
- <input style="width: 100px" type="button" value="新增" id="addbrand" ><br>
- <hr />
- <jsp:useBean id="MyBrand" class="com.lovecoding.study.domian.Brand" scope="page" ></jsp:useBean>
- <jsp:setProperty name="MyBrand" property="brandName" value="达利园" />
- <jsp:setProperty name="MyBrand" property="companyName" value="达利园食品有限公司" />
- <%--<jsp:getProperty name="MyBrand" property="brandName"/> <br />--%>
- <%--<%=MyBrand.getBrandName()%> <br />--%>
- 可以解析: ${MyBrand.brandName} <br />
- 可以解析: ${MyBrand["brandName"]} <br />
- 不正确: ${MyBrand[brandName]} <br />
- <hr />
- <table border="1" cellspacing="0" width="80%">
- <tr>
- <th>序号</th>
- <th>品牌名称</th>
- <th>企业名称</th>
- <th>排序</th>
- <th>品牌介绍</th>
- <th>状态</th>
- <th>操作</th>
- </tr>
- <%-- items 我们要循环的数据源 var 是我们循环得到临时数据变量 --%>
- <c:forEach items="${requestScope.brands}" var="brand" >
- <tr>
- <th>${brand.id}</th>
- <th>${brand.brandName}</th>
- <th>${brand.companyName}</th>
- <th>${brand.ordered}</th>
- <th>${brand.description}</th>
- <th>
- <c:if test="${brand.status == 1}">
- 启动
- </c:if>
- <c:if test="${brand.status != 1}">
- 禁用
- </c:if>
- </th>
- <th>
- <a href="${pageContext.servletContext.contextPath}/updateBrand?id=${brand.id}" > 修改 </a>
- <a href="${pageContext.servletContext.contextPath}/deleteBrand?id=${brand.id}" > 删除 </a>
- </th>
- </tr>
- </c:forEach>
- </table>
- <script>
- document.getElementById("addbrand").onclick = function(){
- location.href="<%=request.getContextPath()%>/addBrand.jsp"
- }
- </script>
- </body>
- </html>
|