开发者

How do I reference my javascript files with this folder structure?

开发者 https://www.devze.com 2023-03-08 06:02 出处:网络
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 t

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....

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 -

/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' -

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

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>

How do I reference my javascript files with this folder structure?


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" 
0

精彩评论

暂无评论...
验证码 换一张
取 消