我有一个使用Tiles 3和Struts 2 Jquery插件的Struts 2应用程序。
在pom.xml中:
<dependency>
<groupId>com.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery-plugin</artifactId>
<version>3.7.1</version>
</dependency>
head.jsp:
<%@ page contentType="text/html" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sb" uri="/struts-bootstrap-tags" %>
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
<s:head />
<!-- struts jquery head -->
<sj:head />
<!-- struts bootstrap head -->
<sb:head />
<!-- main stylesheet -->
<link href="static/css/main.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
浏览器的javascript控制台显示以下错误:Uncaught TypeError: Cannot set property 'version' of undefined
标记<sj:head />
打印以下行:
<script type="text/javascript" src="/MyApp/struts/js/base/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="/MyApp/struts/js/base/jquery.ui.core.min.js?s2j=3.7.1"></script>
<script type="text/javascript" src="/MyApp/struts/js/plugins/jquery.subscribe.min.js?s2j=3.7.1"></script>
<script type="text/javascript" src="/MyApp/struts/js/struts2/jquery.struts2.min.js?s2j=3.7.1"></script>
<script type="text/javascript">
$(function () {
jQuery.struts2_jquery.version = "3.7.1";
jQuery.scriptPath = "/MyApp/struts/";
jQuery.struts2_jquery.gridLocal = "en";
jQuery.struts2_jquery.timeLocal = "en";
jQuery.ajaxSettings.traditional = true;
jQuery.ajaxSetup({
cache: false
});
jQuery.struts2_jquery.require("js/struts2/jquery.ui.struts2.min.js?s2j=3.7.1");
});
</script>
产生未定义错误的行是:
jQuery.struts2_jquery.version = "3.7.1";
经过一些javascript调试后,似乎没有定义函数$.subscribeHandler
。
答案 0 :(得分:1)
问题是由页脚中第二次包含jquery引起的