0

I am developing Spring web application. my application package structure is

web/----|
        |WEB-INF/
             |-jsps/
             |-scripts/
             |-styles/
             |-web.xml

It is Spring MVC & maven based project. I have to use the external javascript file in jsp file. if I use <script src="/scripts/MyFile.js"/> is not working as the resource is inside WEB-INF. I have tried so many ways but I could not find solution. So could you please tell me how to access external javascript file from JSP file.

Note: I cant change my Directory Structure as it is specification. And I should only use external javascript files.

So could you please provide solution. Thanks in adavnce.

Moritz Petersen
  • 12,902
  • 3
  • 38
  • 45
Raju Boddupalli
  • 1,789
  • 4
  • 21
  • 29

2 Answers2

1

You can configure (see: here):

<mvc:resources mapping="/scripts/**" location="/WEB-INF/scripts/" />

Then reference it like:

<script type="text/javascript" src="${context}/scripts/MyFile.js"></script>
Moritz Petersen
  • 12,902
  • 3
  • 38
  • 45
0

Here is the Some other way:


  src="${pageContext.request.contextPath}/jscript/jquery/jquery-1.6.2.js"

We have been using this in our projects. Working perfectly.

Srikanth
  • 534
  • 1
  • 7
  • 20