新建了一个struts2的工程,引入jquery的时候怎么试都不好使,我迷茫了....
<script type="text/javascript" src="${contextPath}/assets/plugins/jQuery/<span style="color:#ff6666;">jQuery-2.2.0.min.js</span>"></script>
<script type="text/javascript">
alert("11111111111");
if (typeof jQuery == 'undefined') {
window.alert("没有jquery");
}
$(function () {
alert("++++++++++++++");
});
alert("22222222222");
</script>
就这么简单的问题...出现了
当我这么引用的时候,确怎么都不好使,有人能看出什么问题不?
我jsp上面的引用是
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="contextPath" value="${pageContext.request.contextPath}"/>
<html>
<head>
<title>index</title>
</head>
<body>
welcome!
</body>
<script type="text/javascript" src="${contextPath}/assets/plugins/jQuery/jQuery-2.2.0.min.js"></script>
<script type="text/javascript">
alert("11111111111");
if (typeof jQuery == 'undefined') {
window.alert("没有jquery");
}
$(function () {
alert("++++++++++++++");
});
alert("22222222222");
</script>
</html>
开始我以为是引入路径的问题,我试了
<script type="text/javascript" src="${pageContext.request.contextPath}/assets/plugins/jQuery/jQuery-2.2.0.min.js"></script>
然后又试了
<script type="text/javascript" src="<%=request.getContextPath()%>/assets/plugins/jQuery/jQuery-2.2.0.min.js"></script>
结果怎么都不对,上网搜也没有个啥结论.
后来我换了个jquery的版本...居然好使了!!!
搞不懂了,谁能告诉我jquery2.2.0这个版本为啥引用了不好使吗?还有什么依赖?
--------------------------------------------------------------
换了浏览器,使用firefox发现所有的引入都是可用的,而IE就只能用jquery比较旧的版本,不知道是不是我的IE版本的问题...
有些问题真的很让我们这些写程序的抓狂...