解决:According to TLD or attribute directive in tag file, attribute value does not accept any express。
2016-08-09 23:04
726 查看
http://blog.csdn.net/lzblog/article/details/22076893
——————————————————————————————————————————————————————————
背景:在mysql中有一个字段声明为datetime类型,在用hibernate映射时对应的类型为java.util.Date。因此从数据 库中读出来,在前台jsp页面显示时,日期格式为年月日,时分秒,毫秒,例1986:07:26 09:07:21 0。日期在实体类和映射文件中已经声明为java.util.Date类型。
实体类代码:
[java] view plain copy
public Date startTime;
public Date closeTime;
hibernate关于这两个字段的映射代码:
[java] view plain copy
<property name="costTime" type="integer">
<column name="CostTime" length="50" not-null="true" />
</property>
<property name="startTime" type="java.util.Date">
<column name="StartTime" length="50" not-null="true" />
</property>
最开始用<s:property value="startTime"></s:property>得出的时间比较怪,是:99-2-26 4:22:50.000
而用el表达式${startTime}得出的时间是1999-02-26 04:22:50.0。
而我想要的时间格式是1999-02-26 04:22:50。
因此用到了jstl标签里的<fmt:formatDate>格式如下:<fmt:formatDate pattern="yyyy:mm:dd HH:mm:ss" value="${startTime}"></fmt:formatDate>
然而报了异常: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库)。
最终页面首部:
[java] view plain copy
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
输出时使用:
[java] view plain copy
<fmt:formatDate pattern="yyyy:mm:dd HH:mm:ss" value="${startTime}"></fmt:formatDate>
注:startTime代表本案例中使用的字段名。
用到的JSTL的jar包:jstl.jar和jstl-standard.jar。下载地址:http://jarfiles.pandaidea.com/。
——————————————————————————————————————————————————————————
背景:在mysql中有一个字段声明为datetime类型,在用hibernate映射时对应的类型为java.util.Date。因此从数据 库中读出来,在前台jsp页面显示时,日期格式为年月日,时分秒,毫秒,例1986:07:26 09:07:21 0。日期在实体类和映射文件中已经声明为java.util.Date类型。
实体类代码:
[java] view plain copy
public Date startTime;
public Date closeTime;
hibernate关于这两个字段的映射代码:
[java] view plain copy
<property name="costTime" type="integer">
<column name="CostTime" length="50" not-null="true" />
</property>
<property name="startTime" type="java.util.Date">
<column name="StartTime" length="50" not-null="true" />
</property>
最开始用<s:property value="startTime"></s:property>得出的时间比较怪,是:99-2-26 4:22:50.000
而用el表达式${startTime}得出的时间是1999-02-26 04:22:50.0。
而我想要的时间格式是1999-02-26 04:22:50。
因此用到了jstl标签里的<fmt:formatDate>格式如下:<fmt:formatDate pattern="yyyy:mm:dd HH:mm:ss" value="${startTime}"></fmt:formatDate>
然而报了异常: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库)。
最终页面首部:
[java] view plain copy
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
输出时使用:
[java] view plain copy
<fmt:formatDate pattern="yyyy:mm:dd HH:mm:ss" value="${startTime}"></fmt:formatDate>
注:startTime代表本案例中使用的字段名。
用到的JSTL的jar包:jstl.jar和jstl-standard.jar。下载地址:http://jarfiles.pandaidea.com/。
相关文章推荐
- Java 集合框架分析:PriorityBlockingQueue java1.8
- squeeze(s1,s2)
- vue.js(二)
- CodeForces-622A.Infinite Sequence
- 安卓入门-UI Components之 ActionBar ,Dialog,Notification ,Toast
- UVALive-7304 - Queue of Soldiers 【动态规划】【组合函数】【好题】
- JavaWeb之servlet的request对象
- java gui 之容器组件
- 极客学院开源硬件视频教程 玩转Arduino
- QuickReport多页打印
- Android Build类
- NavigationBar&Item_About
- validates不要校验布尔型 presence: true
- Poj 3061 Subsequence(二分+前缀和)
- iOS - UITextField
- hdoj 1711 Number Sequence 【KMP 入门--晕晕滴】
- iOS - UIControl
- HDU 1711 Number Sequence(KMP算法)
- poj1679The Unique MST(最小生成树)
- java生成UUID通用唯一识别码 (Universally Unique Identifier)