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类型。

实体类代码:

  1. public Date startTime;
  2. public Date closeTime;

hibernate关于这两个字段的映射代码:

  1. <property name="costTime" type="integer">
  2. <column name="CostTime" length="50" not-null="true" />
  3. </property>
  4. <property name="startTime" type="java.util.Date">
  5. <column name="StartTime" length="50" not-null="true" />
  6. </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库)。

最终页面首部:

  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8" %>
  3. <%@ taglib prefix="s" uri="/struts-tags"%>
  4. <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt"%>
  5. <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>

输出时使用:

  1. <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/。

解决:According to TLD or attribute directive in tag file, attribute value does not accept any express。的更多相关文章

  1. According to TLD or attribute directive in tag file, attribute value does not accept any expressions

    1.错误描写叙述 2014-7-13 17:27:21 org.apache.jasper.compiler.TldLocationsCache tldScanJar 信息: At least one ...

  2. 使用jstl报错:According to TLD or attribute directive in tag file, attribute value does not accept any expressions

    使用jstl报错:According to TLD or attribute directive in tag file, attribute value does not accept any ex ...

  3. According to TLD or attribute directive in tag file, attribute items does not accep t any expressions

    According to TLD or attribute directive in tag file, attribute items does not accep t any expression ...

  4. 使用jstl标签报错:According to TLD or attribute directive in tag file, attribute value

    原来jstl标签版本不一样,标签支持不一样. jstl1.0标签库不支持表达式,如: <c:if test="${query01 == null}">   <js ...

  5. SSH项目中使用struts-tags报错According to TLD or attribute directive in tag file, attribute test does not accept any expressions

    在运行struts2标签页面时报错,代码如下:<%@ page language="java" pageEncoding="gbk"%><%@ ...

  6. 错误处理——According to TLD or attribute directive in tag file, attribute test does not accept any expres

    应用部署运行的时候出现JSP异常, 发生在使用JSTL库的时候: According to TLD or attribute directive in tag file, attribute valu ...

  7. According to TLD or attribute directive in tag file, attribute test does not accept any expressions

    HTTP Status 500 - /WEB-INF/views/emp/list.jsp (line: 30, column: 4) According to TLD or attribute di ...

  8. According to TLD or attribute directive in tag file, attribute end does not accept any expressions

    问题描述: 在 JSP 页面中使用 JSTL 标签库,访问 JSP 页面时抛出了如下异常信息: org.apache.jasper.JasperException: /WEB-INF/manageUs ...

  9. 终极解法According to TLD or attribute directive in tag file, attribute select does not accept any expressions

    3天硬是是把这个问题解决了 有时候突然上个厕所灵感就来了 第一次向用JSTL解析xml 然后我想遍历整个xml文档打印出来 居然不让我输入变量 那让我怎么办啊 在网上各种找答案 说什么<%@ t ...

随机推荐

  1. PHP的生成器、yield和协程

    虽然之前就接触了PHP的yield关键字和与之对应的生成器,但是一直没有场景去使用它,就一直没有对它上心的研究.不过公司的框架是基于php的协程实现,觉得有必要深入的瞅瞅了. 由于之前对于生成器接触不 ...

  2. eclipse 安装properties编辑器,显示中文

    如图添加,地址为: propedit.sourceforge.jp/eclipse/updates/ 选择红框,只安装这个即可 然后一直安装,再接受同意,最后重启eclipse就安装好了 重启后发现文 ...

  3. 88个 Linux 系统管理员必备的监控工具

    随着互联网行业的不断发展,各种监控工具多得不可胜数.这里列出网上最全的监控工具.让你可以拥有超过80种方式来管理你的机器.在本文中,我们主要包括以下方面: 命令行工具 网络相关内容 系统相关的监控工具 ...

  4. Android xUtils3源代码解析之网络模块

    本文已授权微信公众号<非著名程序猿>原创首发,转载请务必注明出处. xUtils3源代码解析系列 一. Android xUtils3源代码解析之网络模块 二. Android xUtil ...

  5. su 和 su -

    单纯使用su切揣到root,读取变量的方式 是non-login shell,这种方式下很多的变量都 不会改变,尤其是PATH,所以root用的很多命令都只能用绝对路径来执行,这种方式只是切换到roo ...

  6. android笔记---主界面(一)

    <?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="htt ...

  7. VS2015终极卸载方法

    今天打开VS2015发现出问题了,总是停止响应,去控制面板里卸载结果像下面这样,卸载出错!于是我有开始折腾了,重新安装一遍然后,还是有问题,在卸载还是出错于是我决定通过安装介质卸载,结果,悲剧的是,启 ...

  8. tornado设置settings

    1.作用 设置应用程序相关参数 2.用法 settings = dict() settings["debug"] = True tornado.web.Application.__ ...

  9. u3d中刚体与碰撞体的理解以及is Trigger属性的意义

    刚体:个人理解就是具有物理属性(如:质量),接受物理作用(如:重力)的组件. 碰撞体:个人理解就是计算碰撞后的物理量(如:弹力). 刚体与碰撞体的关系:个人理解判断碰撞体就是需要计算力,如果碰撞的物体 ...

  10. 多线程消息监听容器配置[ 消费者spring-kafka配置文件]

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...