实际上在我的 Spring 应用程序中我使用的是基于 spring 的form
我的 jsp 代码中的标记。
并为此添加功能<form:input>
,使用Jquery提供DatePicker。
这是我的 Jsp 代码..
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<link rel="stylesheet" href="resources/css/jquery-ui.css" type="text/css">
<link rel="stylesheet" href="resources/css/custom.css" type="text/css">
<script type="text/javascript" src="resources/jquery/jquery-ui.min.js"></script>
<form:form action="form/form1"
modelAttribute="form1">
<label class="control_label_c">From : </label>
<div class="controls_c">
<form:input type="text" path="fromDate" class="date-picker" />
</div>
</form:form>
<script>
$(function() {
$('.date-picker').datepicker( {
changeMonth: true,
changeYear: true,
showButtonPanel: true,
dateFormat: 'MM yy',
onClose: function(dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year, month, 1));
}
});
});
</script>
但日期选择器不起作用(不可见)...
这个基于 spring 的表单标签有什么问题吗?或者
我的代码有什么问题吗?
主要是因为参考问题。请检查以下内容,最好使用Firebug或浏览器中的开发者工具
- 正确引用了兼容 jQuery 版本的 jQuery UI
- jQuery UI CSS 被正确引用
- jQuery UI js 引用
![CDN](https://i.stack.imgur.com/aCyQZ.png)
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)