Spring MVC + Tiles:<! - comments - > not rendering

时间:2012-06-12 11:10:32

标签: xml spring rendering tiles

我正在使用带有Tiles 2.2.2的Spring MVC 3.1.x(带Roo的自举项目)并尝试使用tile模板创建视图,如:

<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 个答案:

答案 0 :(得分:2)

解决方案:Jspx files and conditional comments

总之,jsp文档中的注释被忽略。解决方案是:

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

答案 1 :(得分:1)

尝试使用jsp评论&lt;% - 评论 - %&gt;。希望这对你有所帮助。欢呼声。