解决jsp中input标签读取时间格式实例显示到页面
2016-09-22 15:56
721 查看
java中的代码:
private Date buildTime;
jsp中的代码:
这里我用到了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头部页面如下:
注:buildTime代表本例中的实例字段,currentAccount代表定义的实例常量
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代表定义的实例常量
相关文章推荐
- 在jsp页面/input显示当前时间(初始换时间格式)
- <s:property>标签从后台读取Date类型年份为两位在jsp页面显示的解决方法
- jsp页面input标签中时间日期回显的格式问题&在input标签中指定时间的格式
- jsp中用EL读取了数据库里面的时间,怎么设置格式显示的格式
- jsp页面时间显示格式
- jsp 自定义标签解决jsp页面中int时间戳的时间格式化问题
- 关于jsp页面显示的时间格式和Oracle数据库中的格式不一样的问题
- 把Json格式里的时间戳(13位)在JSP页面格式化显示YYY-MM-dd HH:mm:ss
- Jsp开发自定义标签,自定义标签将字符串转成指定的时间格式显示
- jsp页面时间格式显示不正确
- jsp页面中时间格式化显示,<fmt:formatDate> 标签使用
- jsp中用EL读取了数据库里面的时间,怎么设置格式显示的格式
- spring mvc 在jsp页面如何使时间以格式yyyy-MM-dd HH:mm:ss显示,24小时制
- jsp页面中两种方法显示当前时间的简单实例
- 解决在jsp页面用jstl标签的forEach循环里头格式化时间
- jsp页面转换时间显示格式
- jsp 页面 input 中指定时间格式
- jsp jstl函数 用标签声明页面变量,供jstl使用,时间格式问题
- jsp页面中两种方法显示当前时间的简单实例
- jsp页面显示时间格式