1

My ajax request is not being processed. I receive the warning when starting my server : WARNING: No mapping found for HTTP request with URI [/jquery-1.7.js] in DispatcherServlet with name 'dispatcher'. I think this is occuring because the file jquery-1.7.js is not being found.

<jsp:useBean id="message" scope="request" type="java.lang.String"/>
<html>
<head>
  <title>Spring MVC Ajax Demo</title>
  <script type="text/javascript" src="./jquery-1.7.js"></script>
  <script type="text/javascript">
    function doAjax() {
      alert('here')
      $.ajax({

        url: 'time',
        data: ({name : "me"}),
        success: function(data) {
          $('#time').html(data);
        }
      });
    }
  </script>
</head>
<body>
${message}
<button id="demo" onclick="doAjax()" title="Button">Get the time!</button>
<div id="time">
</div>
</body>
</html>

Do I need to amend the dispatcher entry -

<servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>

</servlet>
<servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
</servlet-mapping>

Update - this helped me : Static files in (Java) App Engine not accessible

Community
  • 1
  • 1
blue-sky
  • 51,962
  • 152
  • 427
  • 752
  • Which version of Spring are you using? Looks simply like your dispatcher is trying to handle the request for a JS file and failing. The dispatcher should not really be handling static resources unless you specifically want it to. Simple answer here - http://stackoverflow.com/questions/870150/how-to-access-static-resources-when-using-default-servlet. – Paul Grime Feb 09 '12 at 22:18

1 Answers1

1

You can either add a <static-files> to appengine-web.xml, including jquery-1.7.js there, or you can get it from google, via

    <script type="text/javascript"
            src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
    </script>
Dave W. Smith
  • 24,318
  • 4
  • 40
  • 46