真是不幸 看来您无法解决这个问题。然后最好的选择是创建自定义的EL函数,该函数将执行相同的操作。这是一个如何替换的示例
fmt:formatDate。
首先创建一个EL函数类(只是一个简单的静态类):
package com.example;import java.text.SimpleDateFormat;import java.util.Date;public final class Functions { private Functions() { // } public static String formatDate(Date date, String pattern) { return new SimpleDateFormat(pattern).format(date); }}然后创建一个
/WEB-INF/functions.tld(注意:以JSP 2.1为目标,不确定您的GAE支持什么,它可能是Servlet
2.4,如果是,则需要将其重新声明为JSP 2.0 taglib):
<?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"> <display-name>Custom Functions</display-name> <tlib-version>1.0</tlib-version> <uri>http://example.com/functions</uri> <function> <name>formatDate</name> <function-class>com.example.Functions</function-class> <function-signature>java.lang.String formatDate(java.util.Date, java.lang.String)</function-signature> </function></taglib>
然后,可以在JSP中如下使用它:
<%@taglib uri="http://example.com/functions" prefix="f" %><jsp:useBean id="date" />...<p>Current year: ${f:formatDate(date, 'yyyy')}</p>


