• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thought I knew WAR structure: Spring MVC/JQuery (simple) path problem

 
K Mansoor
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Folks- I'm stuck with this simple thing. I have a Hello World type Spring MVC based web app and I wanted to play with JQuery, but for the life of me, can't make it work, my jsp just won't 'see' the following:



in my jsp:





I have a feeling something is wrong with the WAR file structure, or do I have to do something Spring related to serve static content?

+root-of-war
WEB-INF/
---jsp/
------myjsp.jsp (this is where i access jquery)
js/
---jquery-1.5.2.js

Please help, I'm stuck since yesterday.
Thanks in advance.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The URL is suspect. It should begin with the context path of the web app. What you have will only work if the web app happens to be the root context.
 
K Mansoor
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I changed the URL to include the context:

This resulted in the following error:

changed the URL to:

added

to mycontext-servlet.xml

changed dir structure to:

+root
resources/
---js/
------jquery-1.5.2.js

And it's working!

Thank you so much for putting me on the right path. I could never have figured it out.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


It'd also be best not to hardcode the context path. You can use:to grab it programmatically.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic