jstl中的format标签
来源:互联网 发布:护肤品网络推广 编辑:程序博客网 时间:2024/06/06 08:59
有格式化:日期,数字的标签:
看例子:
JstlFormatAction.java:
- package com.keith.formatJSTL;
- import java.util.Date;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.apache.struts.action.Action;
- import org.apache.struts.action.ActionForm;
- import org.apache.struts.action.ActionForward;
- import org.apache.struts.action.ActionMapping;
- public class JstlFormatAction extends Action {
- @Override
- public ActionForward execute(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response)
- throws Exception {
- request.setAttribute("today",new Date());
- request.setAttribute("n",123456.784);
- return mapping.findForward("JstlFormatAction");
- }
- }
struts-config.xml:
- <?xml version="1.0" encoding="ISO-8859-1" ?>
- <!DOCTYPE struts-config PUBLIC
- "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
- "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
- <struts-config>
- <action-mappings>
- <action path="/JstlFormatAction"
- type="com.keith.formatJSTL.JstlFormatAction">
- <forward name="JstlFormatAction" path="/FormatJsp.jsp"></forward>
- </action>
- </action-mappings>
- <message-resources parameter="MessageResources" />
- </struts-config>
用到格式化标签,首先要引入标签库:
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
jsp:
- <h2>"l测试format</h2>
- <hr color="orange">
- today(default):<fmt:formatDate value="${today}"/><br>
- today(type="date"):<fmt:formatDate value="${today}" type="date"/><br>
- today(type="time"):<fmt:formatDate value="${today}" type="time"/><br>
- today(type="both"):<fmt:formatDate value="${today}" type="both"/><br>
- today(dateStyle="short"):<fmt:formatDate value="${today}" dateStyle="short"/><br>
- today(dateStyle="medium"):<fmt:formatDate value="${today}" dateStyle="medium"/><br>
- today(dateStyle="long"):<fmt:formatDate value="${today}" dateStyle="long"/><br>
- today(dateStyle="full"):<fmt:formatDate value="${today}" dateStyle="full"/><br>
- today(pattern="yyyy/MM/dd HH:mm:ss"):<fmt:formatDate value="${today}" pattern="yyyy/MM/dd HH:mm:ss"/><br>
- today(pattern="yyyy/MM/dd HH:mm:ss"):<fmt:formatDate value="${today}" pattern="yyyy/MM/dd HH:mm:ss" var="d"/><br>
- ${d }<br>
- <p></p>
- <li>测试数字的格式化</li><br>
- n(default):<fmt:formatNumber value="${n}"/><br>
- n(pattern="###,###.##"):<fmt:formatNumber value="${n}" pattern="###,###.##"/><br>
- n(pattern="###,###.0000"):<fmt:formatNumber value="${n}" pattern="###,###.0000"/><br>
- n(groupingUsed="false"):<fmt:formatNumber value="${n}" groupingUsed="false"/><br>
- n(minIntegerDigits="10"):<fmt:formatNumber value="${n}" minIntegerDigits="10"/><br>
- n(type="currency"):<fmt:formatNumber value="${n}" type="currency"/><br>
- n(type="currency"):<fmt:formatNumber value="${n}" type="currency" currencySymbol="$"/><br>
- n(type="percent"):<fmt:formatNumber value="${p}" type="percent" maxFractionDigits="2" minFractionDigits="2"/><br>
- </body>
1 0
- jstl中的format标签
- jstl中的format标签
- 标签-使用JSTL的format标签
- JSTL中format标签的使用
- jstl中的fn标签
- jstl中的fn标签
- javaweb中的jstl标签
- JSP中的JSTL标签
- Meta标签中的format-detection
- meta标签中的format-detection
- jstl标签配置中的问题
- jstl中的标签type属性
- JSTL标签项目中的使用
- jstl中的<fmt:formatNumber>标签
- jstl中的<fmt:formatNumber>标签
- JSTL中的functions标签使用
- jstl中的<fmt:formatNumber>标签
- jstl中的<fmt:formatNumber>标签
- JAVA字符串
- 关于okhttp和retrofit的使用的疑问
- eclipse提示db-record doesn't exist
- angular 鼠标移入移开元素显示或隐藏
- eclipse中tomcat能正常启动,但是浏览器访问不了tomcat首页 问题解决
- jstl中的format标签
- Python升级pip到更高版本You are using pip version 8.1.1, however version 8.1.2 is available
- 【HUSTOJ】1103: 那些N位数
- (5)Redis封装类
- 事件
- Java 如果阻止二次继承
- Android Drawable图标生成工具
- 职员有薪水了
- 系统升级成win10 后,eclipse的图片打开后成了乱码