Eclipse:动态 web 项目,在哪里放置我下载的 jQuery API
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5577865/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse: dynamic web project, where to put my download jQuery API
提问by Mellon
I have created my dynamic web project in Eclipse. Since my UI use javascript jQuery, I have download the jQuery API, I am wondering where to put it in my eclipse project?. Under which directory? is there any configurations for the jQuery API inside eclipse?
我已经在 Eclipse 中创建了我的动态 Web 项目。由于我的 UI 使用 javascript jQuery,我已经下载了 jQuery API,我想知道将它放在我的 eclipse 项目中的什么位置?. 在哪个目录下?eclipse 中是否有 jQuery API 的任何配置?
回答by csupnig
I'm not quite sure if you just want to know how to provide jQuery for your WebApplication or if you want to be able to develop JavaScript applications with jQuery and have autocompletion for doing so.
我不太确定您是否只是想知道如何为您的 WebApplication 提供 jQuery,或者您是否希望能够使用 jQuery 开发 JavaScript 应用程序并具有自动完成功能。
To use jQuery in your WebApp you can put it somewhere in the WebContent folder. I usually create a "scripts"-folder where I have all the js files.
要在您的 WebApp 中使用 jQuery,您可以将它放在 WebContent 文件夹中的某个位置。我通常会创建一个“脚本”文件夹,其中包含所有 js 文件。
You can then link from your servlet / html file... or whatever to the js file. E.g. you have an index.html in the WebContent directory then you would use the path scripts/jquery.js to link to the js file in the scripts folder.
然后,您可以从您的 servlet/html 文件...或其他任何内容链接到 js 文件。例如,您在 WebContent 目录中有一个 index.html,那么您将使用路径 scripts/jquery.js 链接到脚本文件夹中的 js 文件。
I hope this was some help to you.
我希望这对你有所帮助。
br, Chris
br,克里斯
回答by elbekay
It's up to you where you put it. Once you decide on somewhere include jQuery with script tags on which ever pages you want it. For example:
这取决于你把它放在哪里。一旦您决定在某个地方包含带有脚本标签的 jQuery,您就可以在您想要的页面上使用它。例如:
<script type="text/javascript" src="/path/to/jquery/jquery-1.4.4.min.js"></script>
Obviously the name and version of your jquery .js might be different so update where necessary.
显然,您的 jquery .js 的名称和版本可能不同,因此请在必要时进行更新。
回答by user2787470
create a new folder in your existing project as example script and place jquery.js file.
在现有项目中创建一个新文件夹作为示例脚本并放置 jquery.js 文件。
To include the file in programming just give the path as:
要在编程中包含文件,只需将路径指定为:
<script type="text/javascript" src="/script/jquery/jquery-1.4.4.min.js"></script>