使用JSP显示表格

最近在工做中须要作些前端的工做,固然仍是比较low,使用的JSP。以前没作过,遇到了一些问题,这里记录下。
将后端传过来的List使用表格显示时,免不了要使用html

<c:forEach>
</c:forEach>

要使用这个功能,须要在JSP文件头声明taglib。若是不声明taglib,使用开发者工具(alt+command+i)看返回的数据,发现没有将List展开。前端

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

这样写了以后,若是不在工程的pom中引入相关的jar包依赖的话会有下面的问题。java

HTTP Status 500 - The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

引入的依赖为:web

<dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
        </dependency>

下面是test.jsp的完整代码:后端

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>

<body>

    <div class="row">
        <form class="form-inline" action="/test">
            <div class="form-group">
                <label class="label-middle">开始时间</label><input size="16" type="text" value="${startTime}" name="startTime">
                <label class="label-middle">结束时间</label><input size="16" type="text" value="${endTime}" name="endTime">
                &nbsp; <button type="submit">查询</button>
            </div>
        </form>
    </div>

    <div class="row margin-top-20">
        <table class="table">
            <thead>
            <tr>
                <th class="seq">序号</th>
                <th>时间</th>
                <th>MSG</th>
            </tr>
            </thead>
            <tbody>
            </tbody>
            <c:forEach var="data" items="${datas}" varStatus="loop">
                <tr>
                    <td>${loop.index + 1}</td>
                    <td>${data.time}</td>
                    <td>${data.msg}</td>
                </tr>
            </c:forEach>
        </table>
    </div>
</body>
</html>