利用JSTL重写Java Web MVC实例中的jsp页面
第一步:导入jstl.jar和standard.jar文件
第二步:重写jsp页面
1 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 2 <%@ page import="java.util.*, com.test.bean.EmpBean" %> 3 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 4 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 5 <html> 6 <head> 7 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 8 <title>web01</title> 9 10 <style type="text/css"> 11 body 12 { 13 margin-left: 100px; 14 } 15 table, th, td 16 { 17 border: 1px solid black; 18 } 19 </style> 20 21 </head> 22 <body> 23 <form action="/web01/empController" method="get"> 24 员工姓名:<input type="text" name="searchTxt"> 25 <input type="submit" value="Search"> 26 <table> 27 <tr> 28 <th>员工号</th> 29 <th>员工姓名</th> 30 <th>职位</th> 31 <th>领导号</th> 32 <th>雇佣日期</th> 33 <th>工资</th> 34 <th>奖金</th> 35 <th>部门编号</th> 36 </tr> 37 <c:forEach items="${requestScope.empBean}" var="emp"> 38 <tr> 39 <td>${emp.empNo }</td> 40 <td>${emp.ename }</td> 41 <td>${emp.job }</td> 42 <td>${emp.mgr }</td> 43 <td>${emp.hiredate }</td> 44 <td>${emp.sal }</td> 45 <td>${emp.comm }</td> 46 <td>${emp.deptno }</td> 47 </tr> 48 </c:forEach> 49 </table> 50 </form> 51 </body> 52 </html>
时间: 2024-11-09 00:46:59