java中的代码:
private Date buildTime;
jsp中的代码:
<span style="font-family:KaiTi_GB2312;font-size:12px;"><input type="text" name="buildTime" value="<fmt:formatDate value="${currentAccount.buildTime}" type="both"/>"/></span>
这里我用到了jstl标签里的<fmt:formatDate>格式如下:<fmt:formatDate pattern="yyyy:mm:dd HH:mm:ss" value="${buildTime}"></fmt:formatDate>或是以下这样的写法<fmt:formatDate value="${currentAccount.buildTime}" type="both"/>
添加之后出现一个异常:
异常:According to TLD or attribute directive in tag file, attribute value does not accept any expressions
查询之后得到的解决办法有两种:
一、在page指令里,加入isELIgnored="true"属性,即
<%@ page language="java" contentType="text/html;charset=gbk" isELIgnored="true" %>这个是忽略EL表达式,虽然可以解决问题,但其他处的EL表达式会被当做字符串输出,不建议使用。
二、把<%@ taglib prefix="c" uri="http://java.sun.com/jstl/fmt" %>变为:
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
原理(摘抄):应用部署运行的时候出现JSP异常, 发生在使用JSTL库的时候: According to TLD or attribute directive in tag file, attribute value does not accept any expressions,可能是因为使用了JSP2.0版本, 同时又没有使用JSTL core库的备用版本(RT库)。
最后的jsp头部页面如下:<span style="font-family:KaiTi_GB2312;font-size:12px;"><%@page import="java.util.Date"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %></span>
注:buildTime代表本例中的实例字段,currentAccount代表定义的实例常量