zoukankan      html  css  js  c++  java
  • 解决:According to TLD or attribute directive in tag file, attribute value does not accept any express。

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

  • 相关阅读:
    meta 详解 南京酷得软件
    dojo框架 南京酷得软件
    动软.Net代码自动生成器 南京酷得软件
    Gym 100733 A
    poj 1164 The Castle (入门深搜)
    Gym 100733G No Negations
    Gym 100733C
    关于发邮件时候内嵌图片,在vs2003 里有没有类似LinkedResource 这样的东西
    VS2005里遇到的怪问题,打开vs2005 所有的下拉菜单都变成了全透明的
    discuz!nt里的投票代码
  • 原文地址:https://www.cnblogs.com/cuizhf/p/5754957.html
Copyright © 2011-2022 走看看