Spring MVC JavaScript

In a Spring MVC application, what's the best approach to host external JavaScript files in WEB-INF / along with jsps?

/WEB-INF/spring/foo.jsp, which includes

  <script src="foo.js"></script>. 

I want foo.js in the WEB-INF / spring / directory next to the jsp owner?

I noticed that Spring has ResourceSerlvet, but I'm not sure if this is the way to do this ...

+5
source share
1 answer

WEB-INF does not need to host javascript files. In your WAR file, you can have the following structure:

.
js/
images/
WEB-INF/
WEB-INF/jsp

Jsp files in the WEB-INF \ jsp section are usually displayed in the main application context, so the following will work

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

WEB-INF, . , - JSP include:

<%@include file='js/foo.js'%>

html. javascript, .

+9

All Articles