Datepicker在JSP中不起作用

时间:2016-08-09 21:38:34

标签: jquery jsp spring-mvc datepicker

我有以下JSP文件,每当我尝试填写表单中的日期字段时,它都不会显示datepicker。这是我的employeeForm.jsp:

<%@ page session="false"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>


<html>

<jsp:include page="../common/header.jsp" />

<head>
    <link rel="stylesheet" type="text/css" href="style.css" media="screen" />
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js"></script>
    <script type="text/javascript">
        $( function(){
            $("#date").datepicker(); 
        });
    </script>
</head>

<body>
    <div class="container">


    <spring:url value="/employees" var="employeeActionUrl" />
    <form:form method="POST" modelAttribute="employeeForm" class="form-horizontal" action="${employeeActionUrl}">

        <spring:bind path="name">
            <div class="form-group ${status.error ? 'has-error' : ''}">
                <label class="col-sm-2 control-label">Name</label>
                <div class="col-sm-10">
                    <form:input path="name" type="text" class="form-control" id="name" placeholder="Name"/>
                    <form:errors path="name" class="control-label" />
                </div>
            </div>
        </spring:bind>
        <spring:bind path="ife">
            <div class="form-group ${status.error ? 'has-error' : ''}">
                <label class="col-sm-2 control-label">IFE</label>
                <div class="col-sm-10">
                    <form:input path="ife" type="text" class="form-control" id="ife" placeholder="IFE"/>
                    <form:errors path="ife" class="control-label" />
                </div>
            </div>
        </spring:bind>
        <spring:bind path="profile">
            <div class="form-group ${status.error ? 'has-error' : ''}">
                <label class="col-sm-2 control-label">Profile</label>
                <div class="col-sm-10">
                    <form:input path="profile" type="text" class="form-control" id="profile" placeholder="Profile"/>
                    <form:errors path="profile" class="control-label" />
                </div>
            </div>
        </spring:bind>

        <spring:bind path="department">
            <div class="form-group ${status.error ? 'has-error' : ''}">
                <label class="col-sm-2 control-label">Departament</label>
                <div class="col-sm-10">
                    <form:input path="department" type="text" class="form-control" id="department" placeholder="Departament"/>
                    <form:errors path="department" class="control-label" />
                </div>
            </div>
        </spring:bind>
        <spring:bind path="date">
            <div class="form-group ${status.error ? 'has-error' : ''}">
                <label class="col-sm-2 control-label">Date</label>
                <div class="col-sm-10">
                    <form:input path="date" type="text" id="date"/>
                </div>
            </div>
        </spring:bind>

        <div class="form-actions">
            <input type="submit" value="Submit" class="btn btn-primary btn-sm">
        </div>
    </form:form>

    </div>

<jsp:include page="../common/footer.jsp"/>

</body>
</html>

这是我的header.jsp:

<%@ page session="false"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<head>
<title>ERP</title>

<spring:url value="/resources/admin-lte/bootstrap/css/hello.css" var="coreCss" />
<spring:url value="/resources/admin-lte/bootstrap/css/bootstrap.min.css"
    var="bootstrapCss" />
<spring:url value="/resources/admin-lte/plugins/jquery-ui/jquery-ui.min.css"
    var="jqueryuiCss"/>
<link href="${bootstrapCss}" rel="stylesheet" />
<link href="${coreCss}" rel="stylesheet" />
<link href="${jqueryuiCss}" rel="stylesheet" />
</head>

<spring:url value="/" var="urlHome" />
<spring:url value="/employee/add" var="urlAddEmployee" />

<nav class="navbar navbar-inverse ">
    <div class="container">
        <div class="navbar-header">
            <a class="navbar-brand" href="${urlHome}">ERP</a>
        </div>
        <div id="navbar">
            <ul class="nav navbar-nav navbar-right">
                <li class="active"><a href="${urlAddEmployee}">Add Employee</a></li>
            </ul>
        </div>
    </div>
</nav>

我的footer.jsp:

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<div class="container">
    <hr>
    <footer>
        <p>&copy; Something fancy</p>
    </footer>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>

<spring:url value="/resources/admin-lte/bootstrap/js/hello.js" var="coreJs" />
<spring:url value="/resources/admin-lte/bootstrap/js/bootstrap.min.js"
    var="bootstrapJs" />

<script src="${coreJs}"></script>
<script src="${bootstrapJs}"></script>

提前感谢您的帮助。

0 个答案:

没有答案