如何在 Eclipse 中包含 Javascript 文件以解决 HTML/JSP 文件中的 Javascript 警告?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15216766/
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
How to include Javascript files in Eclipse to resolve Javascript warnings in HTML/JSP files?
提问by Edy Bourne
Here is my situation: I'm working with an application that makes heavy use of JSP includes <%include ... %> and also loads tons of components dynamically using AJAX. All these get loaded into one main template page depending on what the user selects, etc.
这是我的情况:我正在使用一个大量使用 JSP 的应用程序,包括 <%include ... %> 并且还使用 AJAX 动态加载大量组件。所有这些都会根据用户的选择等加载到一个主模板页面中。
My issue is with editing/maintaining these small page fragments that get included and loaded through AJAX. Since they are fragments, their code does not include a and doesn't include things like JQuery, which are added by the main template page.
我的问题是编辑/维护这些通过 AJAX 包含和加载的小页面片段。由于它们是片段,因此它们的代码不包含 a 也不包含 JQuery 之类的内容,这些内容是由主模板页面添加的。
Of course when they are loaded in the browser they work since the fragments are loaded through AJAX and added to the DOM.
当然,当它们在浏览器中加载时,它们会工作,因为这些片段是通过 AJAX 加载并添加到 DOM 中的。
The issue is:since these are just fragments, when I'm maintaining these pages I get a lot of errors and warnings on missing CSS classes and Javascript variables, etc. Besides, I can't use any WYSIWYG editors for the fragments due to the missing imports.
问题是:由于这些只是片段,当我维护这些页面时,我会收到很多关于缺少 CSS 类和 Javascript 变量等的错误和警告。此外,由于以下原因,我无法对片段使用任何 WYSIWYG 编辑器丢失的进口。
How can I tell Eclipse to assume certain imports (e.g. JQuery or CSS sheets)for these fragment files? Since using JSP templates is such a common design pattern I can't believe I'm the only person needing this.
我如何告诉 Eclipse 为这些片段文件承担某些导入(例如 JQuery 或 CSS 表)?由于使用 JSP 模板是如此常见的设计模式,我不敢相信我是唯一需要它的人。
回答by Avinash Singh
You can go to the
你可以去
Eclipse - > Preferences - > JavaScript - > Include Path -> User Libraries
and add a new JavaSCript library.
并添加一个新的 JavaScript 库。
You can give your project JS folder .
你可以给你的项目 JS 文件夹。
After that you can go to your project build path and include that library in build path.
之后,您可以转到项目构建路径并将该库包含在构建路径中。
or you can add it directly to your project from here,
或者您可以从这里直接将其添加到您的项目中,