《SpringBoot极简教程》JSP格式化输出日期

来源:互联网 发布:web优化 sysctl 编辑:程序博客网 时间:2024/06/02 05:30

引入tablib:fmt

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

实例代码如下:

<fmt:formatDate pattern="yyyy/MM/dd HH:mm:ss" value="${blog.gmtModified}"/>

完整jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %><!DOCTYPE html><html lang="en"><head>    <jsp:include page="../header.jsp"></jsp:include></head><body><jsp:include page="../top-nav.jsp"></jsp:include><div class="col-sm-12">    <div>${blog.title}</div>    <div>作者: ${blog.author} 日期: <fmt:formatDate pattern="yyyy/MM/dd HH:mm:ss" value="${blog.gmtModified}"/></div>    <div>${blog.content}</div></div><jsp:include page="../footer.jsp"></jsp:include><footer class="panel-footer rest-footer">    <div class="footer-nav">        <a href="/" target="_blank" hidefocus="true">RestFeel</a>        |        <a href="https://universsky.github.io/" target="_blank">光剑免费图书馆</a>        |        <a href="https://jason-chen-2017.github.io/Jason-Chen-2017/" target="_blank">博客</a>        |        <a href="#" target="_blank" hidefocus="true">微信公众号:ols-lightshadow</a>    </div>    <div class="copyright">RestFeel 2017-7017</div></footer></body></html>