| Author |
Javascript and the DispatcherServlet
|
John Eric Hamacher
Ranch Hand
Joined: Apr 25, 2007
Posts: 223
|
|
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
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
|
|
Your URLs should all start with the context path.
Programatically, it can be obtained via ${pageContext.request.contextPath}
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
John Eric Hamacher
Ranch Hand
Joined: Apr 25, 2007
Posts: 223
|
|
|
Already tried that.
|
 |
John Eric Hamacher
Ranch Hand
Joined: Apr 25, 2007
Posts: 223
|
|
Ok its working, I guess I didn't try putting in the context root with the current <mvc:resources> I tried.
thanks!
|
 |
 |
|
|
subject: Javascript and the DispatcherServlet
|
|
|