当前位置:网站首页>JSTL custom label
JSTL custom label
2022-06-11 13:51:00 【Liangyunliang】
explain
JSTL Not supported by default LocalDate and LocalDateTime, stay JSP Custom display in LocalDate and LocalDateTime, You need to customize the tag to achieve .
First step : Create specific tool classes for transformation
- LocalDateTimeFormatter
public class LocalDateTimeFormatter {
public static String formatLocalDateTime(LocalDateTime localDateTime, String pattern) {
return localDateTime.format(DateTimeFormatter.ofPattern(pattern));
}
}
- LocalDateFormatter
public class LocalDateFormatter {
public static String formatLocalDate(LocalDate localDate, String pattern) {
return localDate.format(DateTimeFormatter.ofPattern(pattern));
}
}
The second step : stay WEB-INF Create under directory tld file
<?xml version="1.0" encoding="UTF-8" ?>
<taglib xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd" version="2.1">
<tlib-version>1.0</tlib-version>
<short-name>Custom_Functions</short-name>
<uri>http://wego.com/format</uri>
<function>
<name>formatLocalDateTime</name>
<function-class>com.wego.formatter.LocalDateTimeFormatter</function-class>
<function-signature>java.lang.String formatLocalDateTime(java.time.LocalDateTime, java.lang.String)</function-signature>
</function>
<function>
<name>formatLocalDate</name>
<function-class>com.wego.formatter.LocalDateFormatter</function-class>
<function-signature>java.lang.String formatLocalDate(java.time.LocalDate, java.lang.String)</function-signature>
</function>
</taglib>
The third step : test
- Server side data
request.setAttribute("localDate", LocalDate.now());
request.setAttribute("localDateTime", LocalDateTime.now());
- Page using
date :${
f:formatLocalDate(localDate, 'yyyy-MM*dd')}
Date time :${
f:formatLocalDateTime(localDateTime, 'yyyy-MM-dd HH:mm:ss')}
边栏推荐
- [the path of system analyst] collection of wrong topics of system analyst
- 【系统分析师之路】系统分析师错题章节集锦
- Hashicopy之nomad应用编排方案07(提交Job)
- 自定义Terraform-Providers(Terraform Plugin Framework)-04
- Terraformer importing cloud resources
- cadence SPB17.4 - group operation(add to group, view group list, delete group)
- cadence SPB17.4 - allegro - allegro_ free_ viewer
- /usr/bin/gzip: 1: ELF : not found /usr/bin/gzip: 3: : not found /usr/bin/gzip: 4: Syntax erro
- Energy storage operation and configuration analysis of high proportion wind power system (realized by Matlab)
- create_ Error in engine MySQL connector encryption method
猜你喜欢

Variable parameter expression

2022.2.28 variable length sequence table

HR doesn't want to read such a PDF technical resume at all. How can it be in the hands of the interviewer?

Some transformation thoughts of programmers after they are 35 years old

JSP实现银柜台业务绩效考核系统

Network information system emergency response

The global mobile phone market is declining, and even apple does not expect too much of the iphone14

YOLOv3学习笔记:YOLOv3的模型结构

Tp6 whoops based exception takeover (beautiful interface)

JDBC连接池去做批量导入,每次运行500万数据,但是在中间就会出各种问题
随机推荐
自定义Terraform-Providers(Terraform Plugin Framework)-04
About PHP: the original deployment environment written by PHP is deployed in phpstudy, PHP + MySQL + Apache. However, the computer must be turned on every time
/usr/bin/gzip: 1: ELF: not found /usr/bin/gzip: 3: : not found /usr/bin/gzip: 4: Syntax erro
Unity detects whether the object is within the viewing cone of the camera
What do you need to do to "surpass" the general database in the time sequence scenario?
[signal de-noising] chromatographic baseline estimation and de-noising based on sparsity (beads) with matlab code and papers
tf.data(二) —— 并行化 tf.data.Dataset 生成器
How about NFT market? Why is NFT so popular? How to build NFT platform
JDBC连接池去做批量导入,每次运行500万数据,但是在中间就会出各种问题
Terraform + Ansible实现基础设施及配置管理
基于FPGA的VGA协议实现
JSP实现银柜台业务绩效考核系统
SQL:如何用采购单销售单的数据 通过移动加权平均法 计算商品成本
Part 23, two-way circular linked list model.
Ecplise cannot connect to SQL Server
C # set the cursor shape of forms and systems
Two small things, feel the gap with the great God
[signal processing] digital signal processing matlab design with GUI interface and report
couldn‘t upgrade db schema: insert into ACT_GE_PROPERTY values (‘common.sche[已解决]
Live share experience