大家,脚本标签
我面临着一个奇怪的问题,包括在JSP页面脚本标签。在这三个剧本中,我只包括第一个在最后一页中进入的脚本。 这里如下我是如何定义的布局
<?xml version="1.0" encoding="UTF-8"?>
<!--$Id$ -->
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
"http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
<tiles-definitions>
<definition name="default" template="/WEB-INF/layouts/default.jspx">
<put-attribute name="header" value="/WEB-INF/views/header.jspx" />
<put-attribute name="submenu" value="/WEB-INF/views/submenu.jspx" />
<put-attribute name="body" value="/WEB-INF/views/body.jspx" />
<put-attribute name="footer" value="/WEB-INF/views/footer.jspx" />
</definition>
<definition name="registration" template="/WEB-INF/layouts/registration.jspx">
<put-attribute name="header" value="/WEB-INF/views/header.jspx" />
<put-attribute name="body" value="/WEB-INF/views/body.jspx" />
</definition>
</tiles-definitions>
视图定义是:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
"http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
<tiles-definitions>
<definition extends="registration" name="register/default">
<put-attribute name="body" value="/WEB-INF/views/register/register.jspx"/>
</definition>
</tiles-definitions>
这里的页面代码(registration.jspx)
<html xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:tiles="http://tiles.apache.org/tags-tiles" xmlns:c="http://java.sun.com/jsp/jstl/core" version="2.0">
<jsp:output doctype-root-element="HTML" doctype-system="about:legacy-compat" />
<jsp:directive.page contentType="text/html;charset=UTF-8" />
<jsp:directive.page pageEncoding="UTF-8" />
<jsp:output omit-xml-declaration="true" />
<head>
<c:url var="rootUrl" value="/resources/" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<link rel="stylesheet" type="text/css" href="/resources/css/screen.css" />
<link rel="stylesheet" type="text/css" href="/resources/css/openid.css" />
<link rel="stylesheet" type="text/css" href="/resources/css/openid-shadow.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"/>
<script type="text/javascript" src="/resources/js/openid-jquery.js"/>
<script type="text/javascript" src="/resources/js/openid-en.js"/>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
openid.init('openid_identifier');
});
//]]>
</script>
<title>Mystery Shopping</title>
</head>
<body>
<tiles:insertAttribute name="header" />
<tiles:insertAttribute name="body" />
</body>
</html>
的波比属性然后在一个名为register.jspx的jspx页面中重写,该页面包含带有openid-selector的表单。资源文件夹也被映射
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- Scans within the base package of the application for @Components to configure as beans -->
<context:component-scan base-package="vm.brands.controller" />
<mvc:resources mapping="/resources/**" location="/resources/" />
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
</beans>
当我访问URL对该登记页面我看到下面的代码(检查通过萤火元素时)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=8">
<link rel="stylesheet" type="text/css" href="/resources/css/screen.css">
<link rel="stylesheet" type="text/css" href="/resources/css/openid.css">
<link rel="stylesheet" type="text/css" href="/resources/css/openid-shadow.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js">
<title>Mystery Shopping</title>
</head>
当我查看网页源(无格式)我确实看到了其他不可见的脚本标签;但是它们“不”显示为源视图中其他标记的格式。
<html version="2.0"><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/><meta content="IE=8" http-equiv="X-UA-Compatible"/><link href="/resources/css/screen.css" type="text/css" rel="stylesheet"/><link href="/resources/css/openid.css" type="text/css" rel="stylesheet"/><link href="/resources/css/openid-shadow.css" type="text/css" rel="stylesheet"/><script src="http://code.jquery.com/jquery-1.7.1.min.js" type="text/javascript"/><script src="/resources/js/openid-jquery.js" type="text/javascript"/><script src="/resources/js/openid-en.js" type="text/javascript"/><script type="text/javascript">
$(document).ready(function() {
openid.init('openid_identifier');
});
我对这种奇怪的行为的原因绝对没有想法。
解决:但一个新的问题弹出
感谢您的帮助拉尔夫;我想你的建议
<spring:url value="/resources/js/openid-jquery.js" var="openid-jquery_url"/>
<spring:url value="/resources/js/openid-en.js" var="openid-en_url"/>
<script src="${openid-jquery_url}" type="text/javascript"><jsp:text> </jsp:text></script>
<script src="${openid-en_url}" type="text/javascript"><jsp:text> </jsp:text></script>
呈现HTML(再次没有想法,为什么和我有点过于分层搜索它;-))
<script src="0" type="text/javascript">
<script src="0" type="text/javascript">
但得到这种形式的工作
<c:url var="rootUrl" value="/resources/" />
<script src="${rootUrl}js/openid-jquery.js" type="text/javascript"><jsp:text> </jsp:text></script>
<script src="${rootUrl}js/openid-en.js" type="text/javascript"><jsp:text> </jsp:text></script>
这给预期的输出
<script src="/resources/js/openid-jquery.js" type="text/javascript">
<script src="/resources/js/openid-en.js" type="text/javascript">
是它与弹簧的一个问题:URL标记或者我失去了一些东西
我不认为这是原因;但你有没有注意到你加载了'jquery-1.7.1.min.js'形式的一个不同的URL'http:// code.jquery.com/jquery-1.7.1.min.js'而不是你的服务器资源? – Ralph 2012-02-24 17:47:30
yeap当我们有一种从jquery服务器的托管模式中获取它的方法时,我觉得将它保存到我的web应用程序是没有用的。我没有使用jquery的spring:url格式,因为它首先被包含在内。 – 2012-02-24 19:20:06