jsp 页面 input 中指定时间格式

1.

<tr>
      <td>生产日期:</td>
     <td><input type="text"  οnclick="WdatePicker()" name="createtime" value="<fmt:formatDate value='${items.createtime}' pattern='yyyy-MM-dd hh:mm:ss'/>"/></td>

 </tr>

 

2.

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>  
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %> 
   <fmt:formatDate var="newdate" value="${items.createtime}" pattern="yyyy-MM-dd"/>
    <input type="text" name="newdate" value="${newdate}"/>

3.另一种
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>  
<%@ taglib prefix="f" uri="http://java.sun.com/jstl/function" %> 
  <input type="text" name="newdate" value="${f:substring(chardate,0,10)}"/>

 

4

把<%@ 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头部页面如下:

<%@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" %>

 

<tr>
      <td>生产日期:</td>
     <td><input type="text"  οnclick="WdatePicker()" name="createtime" value="<fmt:formatDate value='${items.createtime}' pattern='yyyy-MM-dd hh:mm:ss'/>"/></td>

 </tr>

你自己试试啦。。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

?action=1&domain=liebao_my.oschina.net&number=0&version=1&product_no=106&public_index=2&business_index=244&uuid=4c66617f7b9e454a2c59ebdba680fa38&duba_uuid=4c66617f7b9e454a2c59ebdba680fa38&pid=&spid=&tid1=0&tid2=0&tod1=0&tod2=0&lbver=&tryno=0&iid=0&svrid=&os=0&ie=0&wtod2=&usertype_public=0

转载于:https://my.oschina.net/m243043962/blog/1539989

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值