<sql:dateParam value="value"[type="{timestamp|time|date}"]/>
引數說明:<%@page language="java" contentType="text/html;charset=GBK" pageEncoding="GBK"%> <%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%> <sql:setDataSource driver="com.microsoft.jdbc.sqlserver.SQLServerDriver" url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=db_testJSTL" user="sa"password=""/> <% Date date = new Date(new GregorianCalendar(2008,11,1).getTimeInMillis()); request.setAttribute("date",date); %> <sql:query var="rs" sql="SELECT*FROM tb_user WHERE createTime=?"> <sql:dateParam value="${date}" type="date"/> </sql:query>
<%@page language="java"contentType="text/html;charset=GBK" pageEncoding="GBK"%> <%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%> <sql:setDataSource driver="com.microsoft.jdbc.sqlserver.SQLServerDriver" url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=db_testJSTL" user="sa"password=""/> <% Date date = new Date(new GregorianCalendar(2008,11,1,15,24,12).getTimeInMillis()); request.setAttribute("date",date); %> <sql:query var="rs" sql="SELECT*FROM tb_user WHERE createTime=?"> <sql:dateParam value="${date}" type="timestamp"/> </sql:query>