简体   繁体   English

如何在JSP中设置JavaScript路径以显示日期

[英]How can I set the javascript path in my JSP to display date

My web application structure is shown like below. 我的Web应用程序结构如下所示。

tomcat
|--webapps
  |-- META-INF
  |-- WEB-INF
    |-- css
    |--js
    |-- jsp
    |    |-- index.jsp
    |--web.xml

aa I set the JavaScript path in the index.jsp like following: aa我在index.jsp中设置JavaScript路径,如下所示:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="css/jquery-ui.css" />
        <script src="js/jquery-1.8.3.js"></script>
        <script src="js/jquery-ui.js"></script>
        <script>
            $(function() {
                $( "#datepicker" ).datepicker();
            });
        </script>
    </head>
    <body>
        Date: <input type="text" id="datepicker" />
    </body>
</html>

I put all js file under the js folder 我把所有的js文件放在js文件夹下

But it could not load the JavaScript file It display only Date text in JSP page How to I display the date picker in index.jsp page? 但是无法加载JavaScript文件。它仅在JSP页面中显示日期文本。如何在index.jsp页面中显示日期选择器? Please help me... 请帮我...

Move the < in front of "Date:" to the front of "input". 将“日期:”前面的<移到“输入”前面。 Then when you click on the text field you get the date picker. 然后,当您单击文本字段时,您将获得日期选择器。

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI Datepicker - Default functionality</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/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.3/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">
 <script>
 $(function() {
   $( "#datepicker" ).datepicker();
 });
</script>
</head>
   <body>

    <p>Date: <input type="text" id="datepicker"></p>
  </body>
 </html>

i copy pasted this code and made an html file clicked on text field and date picker worked .One of the reason can be internet is not working on your system.Check the internet 我复制粘贴了此代码,并在文本字段和日期选择器上单击了一个html文件。原因之一可能是互联网无法在您的系统上正常工作。

了解结构

for more information about structure see the following link 有关结构的更多信息,请参见以下链接

http://docs.oracle.com/cd/E19146-01/821-1830/abxft/index.html http://docs.oracle.com/cd/E19146-01/821-1830/abxft/index.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM