一:JSTL格式化标签又称为I18N标签库,主要用来编写国际化的WEB应用,使用此功能可以对一个特定的语言请求做出合适的处理。
例如:中国内地用户将显示简体中文,台湾地区则显示繁体中文,使用I18N格式化标签库还可以格式化数字和日期,例如同一数字或日趋,在不同国家可能有不同的格式,使用I18N格式标签库可以将数字和日期格式为当地的格式。

在JSP页面中要使用到格式化标签,需要引入下面的语句:
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"% >

二:概览

格式化标签
<fmt:fromatNumber>
<fmt:formatDate>
<fmt:parseDate>
<fmt:parseNumber>
<fmt:setTimeZone>
<fmt:timeZone>

国际化标签
<fmt:setLocale>
<fmt:requestEncoding>
<fmt:bundle>
<fmt:message>
<fmt:param>
<fmt:setBundle>

三:<fmt:formatNumber>

此标签会根据区域定制的方式将数字格式化成数字,货币,百分比。

此标签的属性:

value:要格式化的数字

type:按照什么类型格式化

pattern:自定义格式化样式

currencyCode:ISO-4721货币代码,只适用于按照货币格式化的数字

currencySymbol: 货币符号,如¥,只适用于按照货币格式化的数字
groupingUsed: 是否包含分隔符
maxIntegerDigits: 整数部分最多显示多少位
mixIntegerDigits: 整数部分最少显示多少位
maxFractionDigits: 小数部分最多显示多位位
minFractionDigits: 小数部分最少显示多位位
var:存储格式化后的结果
scope: 存储的范围

示例1:

Java代码
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>chapter4.jsp</title>
</head>
<body>
<div>
<div>
<fmt:setLocale value="fr_fr"/>
<fmt:formatNumber value="123456789.012"/>
<br/>
<fmt:setLocale value="zh_cn"/>
<fmt:formatNumber value="123456789.012"/>
<br />
<fmt:setLocale value="de_de"/>
<fmt:formatNumber value="123456789.012"/>
<br />
</div>
</div>
</body>
</html>

<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>chapter4.jsp</title>
</head>
<body>
<div>
<div>
<fmt:setLocale value="fr_fr"/>
<fmt:formatNumber value="123456789.012"/>
<br/>
<fmt:setLocale value="zh_cn"/>
<fmt:formatNumber value="123456789.012"/>
<br />
<fmt:setLocale value="de_de"/>
<fmt:formatNumber value="123456789.012"/>
<br />
</div>
</div>
</body>
</html> 注意:如果要实现国际化,那么编码格式要设置为utf-8.
从程序运行效果可以看出,设定的区域不同,格式化数字的显示也会不同.

四:type属性:可以是数字(number),货币(currency),百分比(percent)

示例2:

Java代码
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>chapter4.jsp</title>
</head>
<body>
<div>
<div>
<fmt:setLocale value="zh_cn"/>
<fmt:formatNumber value="0.3" type="number"/><br />
<fmt:formatNumber value="0.3" type="currency"/><br />
<fmt:formatNumber value="0.3" type="percent"/><br />
</div>
</div>
</body>
</html>

<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>chapter4.jsp</title>
</head>
<body>
<div>
<div>
<fmt:setLocale value="zh_cn"/>
<fmt:formatNumber value="0.3" type="number"/><br />
<fmt:formatNumber value="0.3" type="currency"/><br />
<fmt:formatNumber value="0.3" type="percent"/><br />
</div>
</div>
</body>
</html> currencyCode为货币代码,例如美元为USD,人民币为CNY等
currencySymbol为货币符号例如,人民币为¥,美元为$。

如果不指定区域,则会根据语言区域自动选择currencySymbol

示例3:

Java代码
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>chapter4.jsp</title>
</head>
<body>
<div>
<div>
<fmt:setLocale value="zh_cn"/>
<fmt:formatNumber value="0.3" type="currency"/><br />
<fmt:setLocale value="en_Us"/>
<fmt:formatNumber value="0.3" type="currency"/><br />
</div>
</div>
</body>
</html>

<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>chapter4.jsp</title>
</head>
<body>
<div>
<div>
<fmt:setLocale value="zh_cn"/>
<fmt:formatNumber value="0.3" type="currency"/><br />
<fmt:setLocale value="en_Us"/>
<fmt:formatNumber value="0.3" type="currency"/><br />
</div>
</div>
</body>
</html>

currencySymbol属性还可以自定义要显示的头标识,但是一定得type="currency"才会生效,例如:

Java代码
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>chapter4.jsp</title>
</head>
<body>
<div>
<div>
<fmt:setLocale value="zh_cn"/>
<fmt:formatNumber value="0.3" type="currency" currencySymbol="#"/><br />
<fmt:setLocale value="en_Us"/>
<fmt:formatNumber value="0.3" type="currency" currencySymbol="#"/><br />
</div>
</div>
</body>
</html>

<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>chapter4.jsp</title>
</head>
<body>
<div>
<div>
<fmt:setLocale value="zh_cn"/>
<fmt:formatNumber value="0.3" type="currency" currencySymbol="#"/><br />
<fmt:setLocale value="en_Us"/>
<fmt:formatNumber value="0.3" type="currency" currencySymbol="#"/><br />
</div>
</div>
</body>
</html>

自定义数字样式
<fmt:formatNumber value="12.31" pattern=".0000"/><br/>
<fmt:formatNumber value="1234" pattern="###.##E0"/>
会显示:
12.3100
1.234E3
会四舍五入

var:定义一个变量,存储格式化后的结果,scope指定变量存储的范围.用法和前面讲的标签一致.

五:<fmt:parseNumber>

此标签用来将字符串类型的数字,货币或百分比转换成数字类型,和<fmt:formatNumber>标签的作用正好相反.

value: 要转换的字符串
type: 指定要转换的字符串为什么类型,可取值:number,percent,currency
pattern: 自定义格式化样式
parseLocale: 指定区域来转换字符串
IntegerOnly: 转换后的数字是否只显示整数部分
var: 存储转换后的结果
scope: 存储的范围

示例1:
<fmt:parseNumber value="500,800,200"/>
显示: 500800200

示例2:
<fmt:parseNumber value="52%" type="percent" />
显示: 0.52 (52%在这里是一个字符串, type指定这个字符串是什么类型的值)

示例3:
<fmt:parseNumber value="¥123" type="currency" />
显示123, ¥123在这里是一个字符串, type指定这个字符串是什么类型的值

示例4:
<fmt:parseNumber value="123.333" type="number" /><br/>
<fmt:parseNumber value="123.333" type="number" integerOnly="true"/><br/>
显示:
123.333
123
integerOnly确定是否只显示整数部分.

示例5:
<fmt:parseNumber value="¥123.333" type="currency" parseLocale="zh_CN"/><br/>
<fmt:parseNumber value="$123.333" type="currency" parseLocale="en_US"/><br/>
parseLocale="en_US"主要是配合当type="currency"时用的,
如果要转换货币的字符串类型为value="¥123.333",不设置语言环境的话,会取当前浏览器的默认设置,否则就要加上parseLocale="zh_CN",指定环境为中文环境
如果要转换货币的字符串类型为value="$123.333",不设置语言环境的话,会取当前浏览器的默认设置,如果默认为zh_cn的话,程序会报错的,否则就要加上parseLocale="en_US",指定环境为英文美国环境

六:<fmt:formatDate />

此标签可以将日期格式化.
属性介绍:
value 用来格式化的时间或日期
type 指定格式化的是日期还是时间,或者两者都是取值范围:date,time,both
pattern 自定义格式化样式
dateStyle 日期的格式化样式
timeStyle 时间的格式化样式
timeZone 指定使用的时区
var 存储格式化后的结果
scope 指定存储的范围

示例1:

Java代码
<fmt:setLocale value="zh_cn" />
<fmt:formatDate value="<%=new Date()%>" />
<br />
<fmt:setLocale value="zh_tw" />
<fmt:formatDate value="<%=new Date()%>" />

<fmt:setLocale value="zh_cn" />
<fmt:formatDate value="<%=new Date()%>" />
<br />
<fmt:setLocale value="zh_tw" />
<fmt:formatDate value="<%=new Date()%>" />
大家可以看到大陆和台湾显示日期的格式是有区别的.

显示结果:
2009-12-7
2009/12/7

示例2:

Java代码
<fmt:setLocale value="zh_cn" />
<fmt:formatDate value="<%=new Date()%>" type="time"/>
<br />
<fmt:setLocale value="zh_tw" />
<fmt:formatDate value="<%=new Date()%>" type="time"/>

<fmt:setLocale value="zh_cn" />
<fmt:formatDate value="<%=new Date()%>" type="time"/>
<br />
<fmt:setLocale value="zh_tw" />
<fmt:formatDate value="<%=new Date()%>" type="time"/>
显示结果:
14:59:28
下午 02:59:28

type可取值及意义:
date 格式化日期
time格式化时间
both格式化日期时间

示例3:

Java代码
<fmt:setLocale value="zh_cn" />
<fmt:formatDate value="<%=new Date()%>" type="both" />
<br />
<fmt:setLocale value="zh_tw" />
<fmt:formatDate value="<%=new Date()%>" type="both" />

<fmt:setLocale value="zh_cn" />
<fmt:formatDate value="<%=new Date()%>" type="both" />
<br />
<fmt:setLocale value="zh_tw" />
<fmt:formatDate value="<%=new Date()%>" type="both" />
输出结果:
2009-12-7 21:24:26
2009/12/7 下午 09:24:26

dateStyle用来设定日期显示的样式,其值可以是default, short, medium, long, full,请看示例:

Java代码
<fmt:setLocale value="zh_cn" />
<fmt:formatDate value="<%=new Date()%>" type="both" dateStyle="default" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" dateStyle="short" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" dateStyle="medium" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" dateStyle="long" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" dateStyle="full" />
<br />

<fmt:setLocale value="zh_cn" />
<fmt:formatDate value="<%=new Date()%>" type="both" dateStyle="default" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" dateStyle="short" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" dateStyle="medium" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" dateStyle="long" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" dateStyle="full" />
<br />
显示结果如下:
2009-12-7 21:30:49
09-12-7 21:30:49
2009-12-7 21:30:49
2009年12月7日 21:30:49
2009年12月7日 星期一 21:30:49
可以看到dateStyle属性只对日期部分起作用,时间部分没有作用.

timeStyle用来显示时间部分的样式,取值范围同上

Java代码
<fmt:setLocale value="zh_cn" />
<fmt:formatDate value="<%=new Date()%>" type="both" timeStyle="default" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" timeStyle="short" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" timeStyle="medium" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" timeStyle="long" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" timeStyle="full" />
<br />

<fmt:setLocale value="zh_cn" />
<fmt:formatDate value="<%=new Date()%>" type="both" timeStyle="default" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" timeStyle="short" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" timeStyle="medium" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" timeStyle="long" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" timeStyle="full" />
<br />
输出:
2009-12-7 21:35:52
2009-12-7 下午9:35
2009-12-7 21:35:52
2009-12-7 下午09时35分52秒
2009-12-7 下午09时35分52秒 CST

timeZone用来设定时区,时区的意思类似于酒店里大堂放的几个时钟,比如现在时间会有北京时间,东京时间,纽约时间,伦墩时间,
取值范围为:EST, CST, MST, PST

Java代码
<fmt:setLocale value="zh_cn" />
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" timeZone="EST" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" timeZone="CST" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" timeZone="MST" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" timeZone="PST" />
<br />

<fmt:setLocale value="zh_cn" />
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" timeZone="EST" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" timeZone="CST" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" timeZone="MST" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" timeZone="PST" />
<br /> 输出结果:
下午09时41分37秒 CST
上午08时41分37秒 EST
上午07时41分37秒 CST
上午06时41分37秒 MST
上午05时41分37秒 PST

自定义格式:

Java代码
<fmt:setLocale value="zh_cn" />
<fmt:formatDate value="<%=new Date()%>" type="both" pattern="yyyy/MM/dd hh:mm:ss" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" pattern="yyyy-MM-dd HH:mm:ss" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" pattern="yyyy年MM月dd日 hh小时mm分钟ss秒" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" pattern="yy/MM/dd hh:mm:ss" />
<br />

<fmt:setLocale value="zh_cn" />
<fmt:formatDate value="<%=new Date()%>" type="both" pattern="yyyy/MM/dd hh:mm:ss" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" pattern="yyyy-MM-dd HH:mm:ss" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" pattern="yyyy年MM月dd日 hh小时mm分钟ss秒" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="both" pattern="yy/MM/dd hh:mm:ss" />
<br /> 注意这里小时 hh表示12小时制, HH代表24小时制

七:<fmt:parseDate>

将字符串类型的时间转换为日期类型.

value 用来格式化的时间或日期的字符串
type 指定格式化的是日期还是时间,或者两者都是取值范围:date,time,both
pattern 自定义格式化样式
dateStyle 日期的格式化样式
timeStyle 时间的格式化样式
timeZone 指定使用的时区
var 存储格式化后的结果
scope 指定存储的范围

示例:
<fmt:setLocale value="zh_cn" />
<fmt:parseDate type="date" value="2008-4-5"/>
输出: Sat Apr 05 00:00:00 CST 2008,
这里已经将字符串” 2008-4-5”转换为了日期对象了.转换一定得注意,类似于2008-4-5这样的字符串,type必须为date,类似于12:34:56的字符串,type必须为time类似于2008-4-5 12:34:56这样的字符串,type必须为both还要注意浏览器的语言环境的设置,如果为zh_tw,那么字符串就必须得符合当地的标准,如为2009/12/7 下午 09:24:26就正确转换为日期对象,否则就会报错.

八:<fmt:setTimeZone>

value 设定时区
var 存储设定的时区
scope 存储的范围

value用来设定时区,可以是EST,CST,MST,PST等,如果有var属性,则将结果存储在所设定的范围之内.在属性范围内的页面都会使用该时区为默认时区.

Java代码
<fmt:setLocale value="zh_cn" />
<fmt:setTimeZone value="EST" />
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" /><br />
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" /><br />
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" /><br />

<fmt:setLocale value="zh_cn" />
<fmt:setTimeZone value="EST" />
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" /><br />
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" /><br />
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" /><br />
输出:
上午09时25分12秒 EST
上午09时25分12秒 EST
上午09时25分12秒 EST
此时区在该页面内都有效

九:<fmt:timeZone>

用来暂时设置时区.

Java代码
<fmt:setLocale value="zh_cn" />
<fmt:timeZone value="EST">
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" />
<br />
</fmt:timeZone>
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" />

<fmt:setLocale value="zh_cn" />
<fmt:timeZone value="EST">
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" />
<br />
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" />
<br />
</fmt:timeZone>
<fmt:formatDate value="<%=new Date()%>" type="time" timeStyle="full" />
此标签的时区只是部分,在标签开始至标签结束内有效,其它地方无效,其它地方还是会使用默认时区

jstl 格式化的更多相关文章

  1. jstl格式化数字

    jstl中的<fmt:formatNumber>标签   设置显示时间戳<%    request.setAttribute("currentTimeStamp" ...

  2. JSTL 格式化输出 Calendar

    今天遇到一个jstl在页面输出Calendar对象的问题,网上各种百度都说不能直接格式化,但是经过自己的尝试,原来是可以直接格式化的. 做个备忘吧. 对象的createTime字段类型是Calenda ...

  3. jstl格式化日期

    <%@ page contentType="text/html" pageEncoding="GBK"%> <%@ page import=& ...

  4. JSTL格式化标签库

    导入标签库需要使用taglib指令! <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/forma ...

  5. [Java] JSTL格式化时间计算时差

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

  6. jstl格式化页面显示科学计数法问题

    <td content="planEnergy"><fmt:formatNumber value="${gg.planEnergy}" pat ...

  7. JSTL标签库中fmt标签,日期,数字的格式化

    首先介绍日期的格式化:(不要嫌多哦) JSTL格式化日期(本地化) 类似于数字和货币格式化,本地化环境还会影响生成日期和时间的方式. <%@ page pageEncoding="UT ...

  8. JSP 标准标签库(JSTL)

    JSP 标准标签库(JSTL) JSP标准标签库(JSTL)是一个JSP标签集合,它封装了JSP应用的通用核心功能. JSTL支持通用的.结构化的任务,比如迭代,条件判断,XML文档操作,国际化标签, ...

  9. JSTL标签 参考手册

    前言 ========================================================================= JSTL标签库,是日常开发经常使用的,也是众多 ...

随机推荐

  1. 如何用命令将本地项目上传到git,git基本使用

    1.(先进入项目文件夹)通过命令 git init 把这个目录变成git可以管理的仓库 git init 2.把文件添加到版本库中,使用命令 git add .添加到暂存区里面去,不要忘记后面的小数点 ...

  2. 【C++ Primer 第13章】3. 交换操作

    交换操作 class HasPtr { friend void swap(HasPtr &rhs, HasPtr &yhs); //其他成员定义 }; void swap(HasPtr ...

  3. python 防死锁机制

    https://www.cnblogs.com/wongbingming/p/9035575.html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 在编写多线程程序时,可能无意中就会写 ...

  4. otter部署【原创】

    环境IP:10.10.6.171 部署:mysql源库IP:10.10.6.172 部署:mysql目标库IP:10.10.6.173 部署:zookeeper,manager,node,canal ...

  5. Asp.Net Core 2.0 项目实战(2)NCMVC一个基于Net Core2.0搭建的角色权限管理开发框架

    Asp.Net Core 2.0 项目实战(1) NCMVC开源下载了 Asp.Net Core 2.0 项目实战(2)NCMVC一个基于Net Core2.0搭建的角色权限管理开发框架 Asp.Ne ...

  6. Asp.Net Core 2.0 项目实战(5)Memcached踩坑,基于EnyimMemcachedCore整理MemcachedHelper帮助类。

    Asp.Net Core 2.0 项目实战(1) NCMVC开源下载了 Asp.Net Core 2.0 项目实战(2)NCMVC一个基于Net Core2.0搭建的角色权限管理开发框架 Asp.Ne ...

  7. Jmeter如何提取响应头部的JSESSIONID

    近期有柠檬班的学生找到华华,问了一个问题,就是利用Jmeter做接口测试的时候,如何提取头部的JSESSIONID然后传递到下一个请求,继续完成当前用户的请求. 其实,关于这个问题有三种种解决方法: ...

  8. 【Java】 剑指offer(55-1) 二叉树的深度

      本文参考自<剑指offer>一书,代码采用Java语言. 更多:<剑指Offer>Java实现合集   题目 输入一棵二叉树的根结点,求该树的深度.从根结点到叶结点依次经过 ...

  9. Java开发人员必须掌握的Linux命令(二)

    子曰:"工欲善其事,必先利其器." 学习应该是快乐的,在这个乐园中我努力让自己能用简洁易懂(搞笑有趣)的表达来讲解让知识或者技术,让学习之旅充满乐趣,这就是写博文的初心. 本篇的旅 ...

  10. BZOJ.4289.PA2012 Tax(思路 Dijkstra)

    题目链接 \(Description\) 给出一个N个点M条边的无向图,经过一个点的代价是进入和离开这个点的两条边的边权的较大值,求从起点1到点N的最小代价.起点的代价是离开起点的边的边权,终点的代价 ...