此jsp有效:
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"> </script>
<script type="text/javascript" src="jqReady.js"> </script>
</head>
<body>
<div id="hello">Empty</div>
</body>
</html>
此jspx不起作用:
<?xml version="1.0" encoding="utf-8" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"><!-- required for FF3 and Opera --><jsp:text> </jsp:text></script>
<script type="text/javascript" src="jqReady.js"><!-- required for FF3 and Opera --><jsp:text> </jsp:text></script>
</head>
<body>
<div id="hello">Empty</div>
</body>
</html>
</jsp:root>
两者都使用相同的jqReady.js
:
$(document).ready(function() {
$("#hello").text("Hello, world " + new Date());
$("body").css("background-color", "grey");
});
如果jspx,则不会调用传递给ready()
的函数。
使用Firebug我观察到$.isReady
我正在使用Iceweasel 3.5.16(如Firefox 3.5.15),JBoss 7.1.1
相关问题/答案(我已经应用了这些建议):
答案 0 :(得分:0)
我在这里找到了解决方案:HTML5 JSPX template
使用该页面中的模板,此JSPX按预期工作:
<?xml version="1.0" encoding="utf-8" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
<jsp:directive.page contentType="text/html" pageEncoding="utf-8" />
<jsp:output omit-xml-declaration="true" />
<jsp:output doctype-root-element="HTML"
doctype-system="about:legacy-compat" />
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"><!-- required for FF3 and Opera --><jsp:text> </jsp:text></script>
<script type="text/javascript" src="jqReady.js"><!-- required for FF3 and Opera --><jsp:text> </jsp:text></script>
</head>
<body>
<div id="hello">Empty</div>
</body>
</html>
</jsp:root>