spring 3.1.1
tiles 2.2.2
I am attempting to make the output HTML strict but it appears that each "tiles:insertAttribute" add an xml declaration (3 in the example below):
Code:
<?xml version="1.0" encoding="UTF-8"?>
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title>title</title></head>
<body>
<?xml version="1.0" encoding="UTF-8"?>
<div><p>HEADER</p></div>
<?xml version="1.0" encoding="UTF-8"?>
<div><p>CONTEXT</p></div>
<?xml version="1.0" encoding="UTF-8"?>
<div>FOOTER</div></body></html>
webmvc-config.xml:
Code:
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver" id="tilesViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView" />
</bean>
<bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer" id="tilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/layouts/layouts.xml</value>
<value>/WEB-INF/views/**/views.xml</value>
</list>
</property>
</bean>
layouts.xml
Code:
<?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 name="public" template="/WEB-INF/layouts/default.jspx">
<put-attribute name="header" value="/WEB-INF/views/header.jspx" />
<put-attribute name="footer" value="/WEB-INF/views/footer.jspx" />
</definition>
</tiles-definitions>
views.xml
Code:
<?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 name="index" extends="public">
<put-attribute name="title" value="title" />
<put-attribute name="body" value="/WEB-INF/views/index.jspx" />
</definition>
</tiles-definitions>
default.jspx
Code:
<?xml version="1.0" encoding="UTF-8"?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:tiles="http://tiles.apache.org/tags-tiles" version="2.0">
<jsp:directive.page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" session="false" />
<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="true" />
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title><tiles:getAsString name="title" /></title>
</head>
<body>
<tiles:insertAttribute name="header" />
<tiles:insertAttribute name="body"/>
<tiles:insertAttribute name="footer" />
</body>
</html>
</jsp:root>
NOTE: I have tried omit-xml-declaration="true" and "false", and the xml declaration at the top.
header.jspx:
Code:
<div><p>header</p></div>
footer.jspx:
index.jspx: