• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Javascript and the DispatcherServlet

 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello:

My external javascript files are not being recognized in Spring MVC. For example I have:

<script type="text/javascript" src="/js/sample.js"></script>

in my JSP. My javascript files are in a directory called "js" which is immediately inside the context root. Therefore, you would think:

<mvc:resources mapping="/js/**" location="/js/"/>

in the context file would take care of this but it doesn't. I have tried all kinds of variations in the <script> tag and the <mvc:resources> tag to no avail.

I'm looking for ideas because I'm stumped.

Thanks
Eric
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your URLs should all start with the context path.

Programatically, it can be obtained via ${pageContext.request.contextPath}
 
John Eric Hamacher
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Already tried that.
 
John Eric Hamacher
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok its working, I guess I didn't try putting in the context root with the current <mvc:resources> I tried.


thanks!
reply
    Bookmark Topic Watch Topic
  • New Topic