如何将jQuery库包含在Spring-MVC Eclipse项目中 [英] How to include the jQuery library in a Spring-MVC Eclipse project
问题描述
美好的一天,
我已经搜索广泛,但我可以找到的是有关如何添加各种插件到Eclipse的信息。我不想要一个插件。我想要我的stinkin'jQuery!
I have searched far and wide but all I can find is information about how to add various plugins to Eclipse. I don't want a plugin. I want my stinkin' jQuery!
我尝试过的一些事情:
我下载jQuery并把它在我的WebContent\WEB-INF\js文件夹中。然后在我的WebContent\WEB-INF\jsps\company.jsp文件中,我有一个脚本标签:
I download jQuery and put it in my WebContent\WEB-INF\js folder. Then in my WebContent\WEB-INF\jsps\company.jsp file, I have a script tag:
<script type="text/javascript" src="../js/jquery-1.4.3.min.js"></script>
但没有骰子。
窗口 - >首选项 - > JavaScript - >包含路径 - >用户库 - >新建...
Window -> Preferences -> JavaScript -> Include Path -> User Libraries -> New...
这里我添加了我的jQuery库并正确地引用了我的文件。我可以在JavaScript资源中看到我的jQuery库。它看起来就像我预期的那样。但是,我的jQuery脚本不包括在我的页面中。
Here I added my jQuery library and referened my file correctly. I can see my jQuery library in JavaScript Resources. It looks just like I'd expect it. But still, my jQuery script is not included in my page.
我在这里缺少什么?这是一个没有头脑的人,没有人打扰到正确地记录如何做到这一点?如果这样没有脑子,为什么不能弄清楚呢?我想我有一个大脑...
What am I missing here? Is this such a no-brainer that nobody bothers to properly document how to do this? If it's such a no-brainer, why can't I figure it out? I THOUGHT I had a brain...
推荐答案
将我的jquery库移动到这样一个位置的建议是正确的,有一个小例外。需要一个新的servlet来提供静态内容文件。如果有任何人有这个问题,这样的事情应该适合账单:
The advice to move my jquery library to such-and-such a location was correct, with a small exception. A new servlet is required to serve up static content files. If anyone else has this problem, something like this should fit the bill:
<servlet>
<servlet-name>statCont</servlet-name>
<servlet-class>
org.apache.catalina.servlets.DefaultServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>statCont</servlet-name>
<url-pattern>*.js</url-pattern>
</servlet-mapping>
这篇关于如何将jQuery库包含在Spring-MVC Eclipse项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!