我是 JSPX 和 Tiles 的新手。我的瓷砖定义(Tiles 2.2)是:
<tiles-definition>
<definition name="default" template="/WEB-INF/layouts/test.jspx" preparer="com.test.MenuPreparer">
</definition>
</tiles-definition>
我的内容test.jpsx
是:
<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:tiles="http://tiles.apache.org/tags-tiles"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:spring="http://www.springframework.org/tags">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<spring:url value="/scripts/jquery-1.8.1.min.js" var="jqURL" />
<script type="text/javascript" src="${jqURL}"><jsp:text /></script>
</head>
<body>
<h1>TEST!</h1>
</body>
</html>
在我的servlet-context.xml
中,我包含了资源位置:
<resources location="/resources/scripts/" mapping="/scripts/**" />
当我尝试查看页面是 Firefox 14.0.1 时,我在错误控制台中发现以下内容:
TypeError: d is undefined
http://localhost:8080/test/scripts/jquery-1.8.1.min.js
当我在 IE9 中查看同一页面时,我在 IE 控制台中收到以下消息:
SCRIPT5007: Unable to get value of the property 'style': object is null or undefined
jquery-1.8.1.min.js, line 2 character 19451
JQuery 在这两种浏览器中都不起作用。
但是当我在独立的 HTML 中包含相同的 JQuery 脚本(未部署在 tc Server 中)时,我在浏览器控制台中没有收到错误消息并且 JQuery 正在工作。
使用 Spring Web MVC + Apache Tiles + JSPX 时如何使 JQuery 工作?