2012-06-12 42 views
0

我使用Spring MVC 3.1.x與Tiles 2.2.2(使用Roo引導項目)並試圖創建一個視圖,並使用如下模板模板:Spring MVC + Tiles:<! - comments - > not rendering

<html xmlns:jsp="http://java.sun.com/JSP/Page" 
    xmlns:c="http://java.sun.com/jsp/jstl/core" 
    xmlns:tiles="http://tiles.apache.org/tags-tiles" 
    xmlns:spring="http://www.springframework.org/tags" 
    xmlns:util="urn:jsptagdir:/WEB-INF/tags/util" > 

<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" /> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <meta http-equiv="X-UA-Compatible" content="IE=8" />  

    <util:load-scripts /> 

    <spring:message code="application_name" var="app_name" htmlEscape="false"/> 
    <title><spring:message code="welcome_h3" arguments="${app_name}" /></title> 
</head> 
<body> 
    <!--Comments --> 
    <!--[if IE]> 
     something 
    <![endif]--> 
    ... 
    <tiles:insertAttribute name="menu" ignore="true" /> 
    ... 
</body> 
</html> 

Tiles屬性工作正常,但註釋和條件CSS都不呈現;他們只是不出現在輸出代碼中。

任何想法來渲染這個「html評論元素」的代碼?

回答

2

解決方案:Jspx files and conditional comments

綜上所述,在JSP文件的意見被忽略。解決方法是:

<jsp:text><![CDATA[<!--[if lte IE 9]>]]></jsp:text> 
... 
<jsp:text><![CDATA[<![endif]-->]]></jsp:text> 
1

嘗試使用jsp註釋<% - comment - %>。希望這可以幫助你。乾杯。

+0

JSP註釋不會呈現html內容本身。我的問題是,我想渲染德<! - [如果IE] ... - >代碼。 – erramun