0

I have a Spring MVC application it uses jquery.webcam.js this file is located in a js folder in the resources directory on WAR -resources -js,css.. - WEB-INF. Thats the basic structure in the js directory there is a jquery.webcam.js.

When the form that uses jquery.webcam.js and other custom js files is fired its ok it finds all the js files. However on that form i click a button and i am then posted to another page, on this page i have a hyper link that has a url of "getData/${id}.htm". When i click on the hlink i am taken to the controller which has a mapping for this url:

 @RequestMapping(value="getData/{id}.htm", method = RequestMethod.GET) 

In the controller a select is preformed from the database and an object is returned to the previous page (first form - that uses the jquery.webcam.js). When i am returned to that page i am getting in firebug a 404 error for the jquery.webcam.js file.

Upon further inspection the url for the location of my resources has changed from http://localhost:8080/myApp/jquery.webcam.js to http://localhost:8080/myApp/getData/jquery.webcam.js

Why has getData now became part of the resources url and how can this be fixed?

Mallikarjuna Reddy
  • 1,212
  • 2
  • 20
  • 33
devdar
  • 5,564
  • 28
  • 100
  • 153

1 Answers1

1

Script files should be loaded like below..

If your js folder is under resource folder.

<script src="<%=request.getContextPath()%>/js/jquery.webcam.js"></script>

Mallikarjuna Reddy
  • 1,212
  • 2
  • 20
  • 33
  • 1
    just asking did you miss out the resources directory i had to use for it ot work. Also is it the same for css files? – devdar Mar 14 '13 at 15:07
  • 1
    yes ofcourse , in your case mentioning resource may be required. Normally it is not required if you folders are in webcontent. – Mallikarjuna Reddy Mar 14 '13 at 18:11
  • i am also getting the issue happening again hope you dont mind looking at this for me http://stackoverflow.com/questions/15416447/springmvc-http-status-405-request-method-post-not-supported?noredirect=1#comment21799926_15416447 – devdar Mar 14 '13 at 18:14