我有一个使用 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>
头.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
没有定义该函数。