jsp页面初始化日期格式

jsp页面<head>前添加一段代码:
<%
    Date date =new Date();
    SimpleDateFormat format =new SimpleDateFormat("yyyy-MM-dd");
    String _startDate =format.format(date)+" 00:00:00";
    String _endDate =format.format(date)+" 23:59:59";
    request.setAttribute("_startDate", _startDate);
    request.setAttribute("_endDate", _endDate);
%>
body里面添加:
<tr>
    <td class="title_2" width="15%">告警发生开始时间:</td>
    <td width="15%" align="left">
        <lk:date id="startTime" name="startTime" type="all" defaultDate="%{#request._startDate}" /> 
    <label class="red">*</label></td>
    </td>
    <td class="title_2" width="15%">告警发生结束时间:</td>
    <td width="15%" align="left">
        <lk:date id="endTime" name="endTime" type="all" defaultDate="%{#request._endDate}"/> 
    <label class="red">*</label></td>
    </td>
</tr>

猜你喜欢

转载自blog.csdn.net/shannon8/article/details/72722674