首页 > 代码库 > JSTL I18N 格式标签库

JSTL I18N 格式标签库

<%@ page language="java" pageEncoding="gbk"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<jsp:useBean id="date" class="java.util.Date"></jsp:useBean>
<html>
    <head>
        <title>I18N标签库</title>
    </head>
    <body>
        <H4>
            <c:out value="http://www.mamicode.com/标签的使用"></c:out>
        </H4>
        <hr>
        <fmt:setLocale value="http://www.mamicode.com/en_us" />
        英文:
        <fmt:formatDate value="http://www.mamicode.com/${date}" type="both" dateStyle="full"
            timeStyle="full" />
        <hr>
        <fmt:setLocale value="http://www.mamicode.com/zh_cn" />
        中文:
        <fmt:formatDate value="http://www.mamicode.com/${date}" type="both" dateStyle="full"
            timeStyle="full" />
        <hr>
        <fmt:setLocale value="http://www.mamicode.com/zh_TW" />
        中国台湾:
        <fmt:formatDate value="http://www.mamicode.com/${date}" type="both" dateStyle="full"
            timeStyle="full" />
    </body>
</html>
<%@ page language="java" pageEncoding="gbk"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<jsp:useBean id="date" class="java.util.Date"></jsp:useBean>
<html>
    <head>
        <title>I18N标签库</title>
    </head>
    <body>
        <fmt:formatDate value="http://www.mamicode.com/${date}"></fmt:formatDate>
        <br>
        <fmt:formatDate value="http://www.mamicode.com/${date}" type="both"></fmt:formatDate>
        <br>
        <fmt:formatDate value="http://www.mamicode.com/${date}" type="both" dateStyle="default"
            timeStyle="default"></fmt:formatDate>
        <br>
        <fmt:formatDate value="http://www.mamicode.com/${date}" type="both" dateStyle="short"
            timeStyle="short"></fmt:formatDate>
        <br>
        <fmt:formatDate value="http://www.mamicode.com/${date}" type="both" dateStyle="long"
            timeStyle="long"></fmt:formatDate>
        <br>
        <fmt:formatDate value="http://www.mamicode.com/${date}" type="both" dateStyle="full"
            timeStyle="full"></fmt:formatDate>
        <br>
        <fmt:formatDate value="http://www.mamicode.com/${date}" type="both" dateStyle="full"
            timeStyle="full"></fmt:formatDate>
        <br>
    </body>
</html>


本文出自 “阿凡达” 博客,请务必保留此出处http://shamrock.blog.51cto.com/2079212/1537253