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. 第7讲 SPI和RAM IP核

    学习目的: (1) 熟悉SPI接口和它的读写时序: (2) 复习Verilog仿真语句中的$readmemb命令和$display命令: (3) 掌握SPI接口写时序操作的硬件语言描述流程(本例仅以写 ...

  2. [100]linux常用命令参数小结

    1.mkdir 2.ls -l -d 显示目录 -F 给文件夹结尾加/标识 -a 以.开头的都是隐藏文件 -rt 按照修改时间倒序排列(最新修改的在最下) ls -lhrt #最新的在下面 3.cd ...

  3. Requests: 让 HTTP 服务人类

    requests 2.18.1文档 requests流式post文件 Calling SOAP Web service using requests module of

  4. Android自定义AlertDialog

    常见的一种方法: [html] view plaincopyprint? AlertDialog.Builder builder; AlertDialog alertDialog; LayoutInf ...

  5. [翻译] Dremel made simple with Parquet

    首先自己的 blog 好久没有写技术相关的东西了,今天又动笔了,好高兴!然后转载请注明出处.最后开始正题: 原文:Dremel made simple with Parquet | Twitter E ...

  6. 获取windows可执行文件的version信息(版本号)

    之前在msdn上Version Information看到文件版本信息的介绍,看着整体比较复杂,就一直没做.现在需要获取ocx文件的版本号,所以查找了下相关资料,比较有用的就是VS_FIXEDFILE ...

  7. spring IOC 模拟实现

    IOC即inverse of control 控制反转 以前对象之间的引用是通过new来调用实现,有了Spring IOC,我们可以把对象之间的引用交给他来管理,这样就把控制权交给了Spring,所以 ...

  8. spring 强制采用cglib进行代理

    spring对AOP的支持 *如果目标对象实现了接口,默认情况下会采用JDK的动态代理实现AOP* 如果目标对象实现了接口,可以强制使用CGLIB实现AOP*如果目标对象没有实现了接口,必须采用CGL ...

  9. celery 实例进阶

    认识 这里有几个概念,task.worker.broker.顾名思义,task 就是老板交给你的各种任务,worker 就是你手下干活的人员. 那什么是 Broker 呢? 老板给你下发任务时,你需要 ...

  10. SQLite 入门教程一 基本控制台(终端)命令

    一.基本简介 SQLite 是一个自持的(self-contained).无服务器的.零配置的.事务型的关系型数据库引擎.因为他很小,所以也可以作为嵌入式数据库内建在你的应用程序中.SQLite 被应 ...