Spring MVC 和 Bootstrap - css,img 工作.js不工作
Spring MVC and Bootstrap - css, img working .js not working
我正在使用带有Spring Template MVC项目的STS Eclipse。我想使用Bootstrap,我在webapp/resources下创建了css,js和img目录,并将所有需要的文件放在这些文件夹下。我对.css文件没有问题,而我找不到.js文件。应用程序可以正确使用外部.js引用。
下面是 Dispatcher servlet:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<context:component-scan base-package="org.dani.bootstrap" />
</beans:beans>
这是 js 脚本的 jsp 部分
<script type="text/javascript" src="<c:url value="resources/js/bootstrap.js"/>"> </script>
<!-- <script src="<c:url value="/resources/js/bootstrap-dropdown.js"/>"> </script>-->
<script type="text/javascript" src="<c:url value="resources/js/jquery-1.9.0.min.js" />"> </script>
<script type="text/javascript" src="<c:url value="resources/js/jquery-migrate-1.0.0.min.js" />"></script>
我需要知道我做错了什么
为了提高可见性,您应该将 url 变量和脚本分开。您应该通过添加"/"在 URL 中包含完整路径。试试这个:
<mvc:resources location="resources/" mapping="/resources/**"/>
<c:url value="/resources/js/jquery-1.9.0.min.js" var="jqueryUrl"/>
<script src="${jqueryUrl}" type="text/javascript"><!-- required for FF3 and Opera --></script>
相关文章:
- addEventListener的Javascript代码不工作!?(单击时打开放大的img)
- Django,HTML,JS:<img src=“#">可以在HTML中工作,但不能在JS文件中工作
- JavaScript on Click 事件在 img 标签上无法正常工作
- 如何将img维度从html移动到css并保持此滑块工作
- 如何在加载img后强制脚本工作
- css img:悬停工作,img:活动无效
- JavaScript img onclick 引用错误才能正常工作
- 如果图像工作正常,为什么 img onerror 处理程序会执行
- 解释 var img = new Image();的工作
- 悬停在图像上会将其更改为悬停img.但是单击图像后,悬停停止工作
- 我可以'我的Jquery无法正常工作:需要在单击时动态添加img标记
- 当鼠标悬停父元素在ie中不工作时,更改img SRC
- Javascript改变img src不工作
- 为什么onerror事件不工作的img标签,当jquery放在页脚
- 响应式img映射jQuery插件不工作
- Javascript用YouTube视频代替IMG -自动播放不能正常工作
- Spring MVC 和 Bootstrap - css,img 工作.js不工作
- 背景颜色不工作与img
- 当我迭代图像链接数组并使用innerHTML显示它们时,为什么IMG标记不能工作?
- img onload没有'我在IE7中工作不好