我想用明天的日期(服务器端,而不是客户端)设置日期选择器。
我从jsp尝试了这个jquery datepicker set minDate和maxDate,并添加了:
<%
try {
Date now = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(now);
cal.add(Calendar.DAY_OF_YEAR, 1);
Date tomorrow = cal.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
} catch (Exception e) {
System.out.println(e.getStackTrace());
}
%>
<script type="text/javascript">
var date = '<%=sdf.format(tomorrow) %>';
但我同时获得了sdf cannot be resolved
例外tomorrow cannot be resolved
。
我在jsp页面中java.util.*
都导入了:java.text.SimpleDateFormat
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.*" %>