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.

4

2 回答 2

1

您可以配置(参见:此处):

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

然后像这样引用它:

<script type="text/javascript" src="${context}/scripts/MyFile.js"></script>
于 2013-09-02T11:22:57.793 回答
0

这是其他方式:

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

我们一直在我们的项目中使用它。工作完美。

于 2013-09-02T11:56:39.803 回答