日期选取器在包含在另一个 JSP 文件中时不起作用



我有一个文件Inside.jsp它包含在文件总数.jsp中。我在 Inside.jsp 中有一个输入字段。当您单击它时,屏幕上应该会出现一个日历。如果您在浏览器中,日历 http://localhost:8080/inside.jsp 打开,但如果您在 http://localhost:8080/total.jsp 则没有任何反应(日历不会打开,而只是一个普通的输入字段)。我能做些什么来解决这个问题?

我相信它与我的脚本或链接有关,但最好得到解释。

内部.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" name="viewport"
    content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="../css/total.css">
<link rel="stylesheet"
    href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script
    src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>

<script>
    $(function() {
        $("#pickdate").datepicker();
    });
</script>

<title>Inside</title>
</head>
<body>
<input type="text" id="pickdate" class="form-control">

</body>
</html>

共.jsp条记录:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link
    href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"
    rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="../css/total.css">

<title>Total</title>
</head>
<body>

    <divt><jsp:include page="Inside.jsp" /></div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js></script>
    <script
    src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</body>
</html>

您实际上在另一个页面中包含了一个完整的 HTML 页面,头部和身体部位已经在 Total.jsp 页面中,要解决这样的问题,内部.jsp应该保持清洁。只是您想要的内容,您应该将库和 CSS 加载移动到 总计.jsp.

并保留内部.jsp仅包含字段和将日期纠察队与字段相关联的脚本。

共.jsp条记录:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link
    href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"
    rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="../css/total.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<title>Total</title>
</head>
<body>

    <divt><jsp:include page="Inside.jsp" /></div>
</body>
</html>

内部.jsp:

<script>
    $(function() {
        $("#pickdate").datepicker();
    });
</script>
<input type="text" id="pickdate" class="form-control">

最新更新