Advertisement
uopspop

Untitled

Oct 23rd, 2016
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.59 KB | None | 0 0
  1. <%@ page contentType="text/html; charset=UTF-8" pageEncoding="Big5"%>
  2. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
  3. <%@ page import="java.util.*"%>
  4. <%@ page import="com.emp.model.*"%>
  5. <%-- 此頁練習採用 EL 的寫法取值 --%>
  6.  
  7. <%
  8.     EmpService empSvc = new EmpService();
  9.     List<EmpVO> list = empSvc.getAll();
  10.     pageContext.setAttribute("list",list);
  11. %>
  12. <jsp:useBean id="deptSvc" scope="page" class="com.dept.model.DeptService" />
  13.  
  14. <html>
  15. <head>
  16. <title>所有員工資料 - listAllEmp.jsp</title>
  17. </head>
  18. <body bgcolor='white'>
  19. <b><font color=red>此頁練習採用 EL 的寫法取值:</font></b>
  20. <table border='1' cellpadding='5' cellspacing='0' width='800'>
  21.     <tr bgcolor='#CCCCFF' align='center' valign='middle' height='20'>
  22.         <td>
  23.         <h3>所有員工資料 - ListAllEmp.jsp</h3>
  24.         <a href="<%=request.getContextPath()%>/select_page.jsp"><img src="images/back1.gif" width="100" height="32" border="0">回首頁</a>
  25.         </td>
  26.     </tr>
  27. </table>
  28.  
  29. <%-- 錯誤表列 --%>
  30. <c:if test="${not empty errorMsgs}">
  31.     <font color='red'>請修正以下錯誤:
  32.     <ul>
  33.         <c:forEach var="message" items="${errorMsgs}">
  34.             <li>${message}</li>
  35.         </c:forEach>
  36.     </ul>
  37.     </font>
  38. </c:if>
  39.  
  40. <table border='1' bordercolor='#CCCCFF' width='800'>
  41.     <tr>
  42.         <th>員工編號</th>
  43.         <th>員工姓名</th>
  44.         <th>職位</th>
  45.         <th>雇用日期</th>
  46.         <th>薪水</th>
  47.         <th>獎金</th>
  48.         <th>部門</th>
  49.         <th>修改</th>
  50.         <th>刪除</th>
  51.     </tr>
  52.     <%@ include file="pages/page1.file" %>  <%/* 得到總資料筆數 + 定義每頁比數 + 根據使用者的選擇處理pageIndex */ %>
  53.     <c:forEach var="empVO" items="${list}" begin="<%=pageIndex%>" end="<%=pageIndex+rowsPerPage-1%>">
  54.         <tr align='center' valign='middle' ${(empVO.empno==param.empno) ? 'bgcolor=#CCCCFF':''}><!--將修改的那一筆加入對比色而已-->
  55.             <td>${empVO.empno}</td>
  56.             <td>${empVO.ename}</td>
  57.             <td>${empVO.job}</td>
  58.             <td>${empVO.hiredate}</td>
  59.             <td>${empVO.sal}</td>
  60.             <td>${empVO.comm}</td>         
  61.             <td><c:forEach var="deptVO" items="${deptSvc.all}">
  62.                     <c:if test="${empVO.deptno==deptVO.deptno}">
  63.                         ${deptVO.deptno}【${deptVO.dname} - ${deptVO.loc}
  64.                     </c:if>
  65.                 </c:forEach>
  66.             </td>
  67.             <td>
  68.               <FORM METHOD="post" ACTION="<%=request.getContextPath()%>/emp/emp.do">
  69.                  <input type="submit" value="修改">
  70.                  <input type="hidden" name="empno" value="${empVO.empno}">
  71.                  <input type="hidden" name="requestURL" value="<%=request.getServletPath()%>"><!--送出本網頁的路徑給Controller-->
  72.                 <input type="hidden" name="whichPage"   value="<%=whichPage%>">               <!--送出當前是第幾頁給Controller-->
  73.                  <input type="hidden" name="action" value="getOne_For_Update"></FORM>
  74.             </td>
  75.             <td>
  76.               <FORM METHOD="post" ACTION="<%=request.getContextPath()%>/emp/emp.do">
  77.                 <input type="submit" value="刪除">
  78.                 <input type="hidden" name="empno" value="${empVO.empno}">
  79.                 <input type="hidden" name="requestURL"  value="<%=request.getServletPath()%>"><!--送出本網頁的路徑給Controller-->
  80.                 <input type="hidden" name="whichPage"   value="<%=whichPage%>">               <!--送出當前是第幾頁給Controller-->
  81.                 <input type="hidden" name="action"value="delete"></FORM>
  82.             </td>
  83.         </tr>
  84.     </c:forEach>
  85. </table>
  86. <%@ include file="pages/page2.file" %>
  87.  
  88. <br>本網頁的路徑:<br><b>
  89.    <font color=blue>request.getServletPath():</font> <%= request.getServletPath()%><br>
  90.    <font color=blue>request.getRequestURI(): </font> <%= request.getRequestURI()%> </b>
  91. </body>
  92. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement