一、在input标签中格式化代码
<input name="report_date" type="text" class="dfinput" value="<fmt:formatDate value="${sessionScope.report.report_date}" type="date" />" onClick="WdatePicker({work_date:'',dateFmt:'yyyy-MM-dd'})"/>
但是容易报错
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”%>
二、后端传到前端的date类型,jsp格式化
<fmt:formatDate value="${report.report_date}" type="date"></fmt:formatDate>
需要引入标签库
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>