javascripthtmljqueryjspstruts2

Can't get jQuery datepicker in Struts 2


I want to use jQuery datepicker in my Struts app

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!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" content="text/html; charset=UTF-8">
<title>My First JQuery Page</title>
<link rel="stylesheet" type="text/css" href="css/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="css/mytestcss.css">
<script src="/js/jquery-1.11.1.js"></script>
<script src="/js/jquery-ui.js"></script>
<script>
    $(function() {
     $( "#datepicker" ).datepicker();
    });
</script>
</head>
<body>
  <div id="formdiv">
    <s:form>
        <s:textfield label="username" name="username" ></s:textfield>
        <s:password label="password" name="password" ></s:password>
        <s:textfield label="date" id="datepicker" name="date"></s:textfield>
        
    </s:form>
  </div>
  <input type="text" id="datepicker">
</body>
</html>

Did I miss anything? Why datepicker is not loading?


Solution

  •     <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <%@ taglib prefix="s" uri="/struts-tags"%>
    <!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" content="text/html; charset=UTF-8">
    <title>My First JQuery Page</title>
    <link rel="stylesheet" type="text/css" href="css/jquery-ui.css">
    <link rel="stylesheet" type="text/css" href="css/mytestcss.css">
    <script src="js/jquery-1.11.1.js"></script>
    <script src="js/jquery-ui.js"></script>
    <script>
        $(function() {
         $( "#datepicker" ).datepicker();
        });
    </script>
    </head>
    <body>
      <div id="formdiv">
        <s:form>
            <s:textfield label="username" name="username" ></s:textfield>
            <s:password label="password" name="password" ></s:password>
            <s:textfield label="date" id="datepicker" name="date"></s:textfield>
    
        </s:form>
      </div>
    
    </body>
    </html>
    

    The .js file was not loaded ,because of /js/jquery-1.11.1.js i changed it to js/jquery-1.11.1.js (removed '/')