0

我是 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 工作?

4

1 回答 1

0

阅读后,当我包含 jquery 时,为什么我的简单严格的 XHTML 文件会出错?,我添加了以下行test.jspx

<jsp:output doctype-root-element="html" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" omit-xml-declaration="yes" /> 

它现在正在工作。

于 2012-09-04T11:28:20.880 回答