如何使用此文件夹结构引用我的javascript文件?

时间:2021-12-29 20:20:47

This is a very simple thing that I can't seem to get to work. What is the correct way for referencing my resources folder in my script and link tags? Is there a trick to this since my URLs are mapped to Spring resources? Do I have to do anything special since my resources folder isn't in my WEB-INF folder? Do I need to move it into the WEB-INF folder? If I do move it there, how would it be referenced inside the WEB-INF folder. I have tried everything I can think of, including....

这是一件非常简单的事情,我似乎无法开始工作。在我的脚本和链接标记中引用我的资源文件夹的正确方法是什么?有没有一个技巧,因为我的URL被映射到Spring资源?我的资源文件夹不在我的WEB-INF文件夹中,我是否必须做任何特殊的事情?我需要将其移动到WEB-INF文件夹中吗?如果我在那里移动它,它将如何在WEB-INF文件夹中引用。我已经尝试了我能想到的一切,包括....

With folder in current position -

文件夹在当前位置 -

/WebContent/resources/scripts/jquery-1.6.1.min.js
/resources/scripts/jquery-1.6.1.min.js
../resources/scripts/jquery-1.6.1.min.js
../../resources/scripts/jquery-1.6.1.min.js
/../resources/scripts/jquery-1.6.1.min.js
/../../resources/scripts/jquery-1.6.1.min.js

With folder inside WEB-INF -

使用WEB-INF内的文件夹 -

/resources/scripts/jquery-1.6.1.min.js
../resources/scripts/jquery-1.6.1.min.js
../../resources/scripts/jquery-1.6.1.min.js
/../resources/scripts/jquery-1.6.1.min.js
/../../resources/scripts/jquery-1.6.1.min.js

Are any of these right?

这些都对吗?

I'm getting this in my console when I use 'resources/scripts/jquery-1.6.1.min.js' -

当我使用'resources / scripts / jquery-1.6.1.min.js'时,我在我的控制台中得到这个 -

May 23, 2011 11:30:19 AM org.springframework.web.servlet.DispatcherServlet     noHandlerFound
WARNING: No mapping found for HTTP request with URI 
[/ProjectName/resources/styles/global.css] in DispatcherServlet with name 'spring'

home.jsp -

home.jsp -

<html>
  <head>
    <title>
  title goes here
</title>
    <script type="text/javascript" src="/WebContent/resources/scripts/global.js"></script>
    <script type="text/javascript" src="/WebContent/resources/scripts/jquery-1.6.1.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/WebContent/resources/styles/global.css" media="screen" />
    <script type="text/javascript">
      $(document).ready(
        function(){
        alert('hello');
      });
    </script>
  </head>
  <body>
    ${message}
    <input id="inputField"></input>
  </body>
</html>

如何使用此文件夹结构引用我的javascript文件?

1 个解决方案

#1


3  

Replace for this:

替换为:

<script type="text/javascript" src="resources/scripts/global.js"></script>
<script type="text/javascript" src="resources/scripts/jquery-1.6.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="resources/styles/global.css" media="screen" 

#1


3  

Replace for this:

替换为:

<script type="text/javascript" src="resources/scripts/global.js"></script>
<script type="text/javascript" src="resources/scripts/jquery-1.6.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="resources/styles/global.css" media="screen"