XML namespace

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

XML namespace

menganox
Hi,

I'm facing some problem with SpringMVC-Tiles-Thymeleaf.
I can't make it work, now because I can't set xmlns up properly, I think.
My baselayout looks like:


<i><!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring3-3.dtd">

<html 
	xmlns="http://www.w3.org/1999/xhtml" 
	xmlns:th="http://www.thymeleaf.org" 
	xmlns:tiles="http://www.thymeleaf.org"
    xmlns:spring="http://www.springframework.org/tags" 
>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title><tiles:insertAttribute name="title" ignore="true" /></title>
		<link rel="stylesheet" type="text/css" media="all" href="../../css/style.css" th:href="@{/css/style.css}" />
	</head>
	<body>
		<table border="1" cellpadding="2" cellspacing="2" align="center">
			<tr>
				<td height="30" colspan="2"><tiles:insertAttribute name="header" />
				</td>
			</tr>
			<tr>
				<td height="250"><tiles:insertAttribute name="menu" /></td>
				<td width="350"><tiles:insertAttribute name="body" /></td>
			</tr>
			<tr>
				<td height="30" colspan="2"><tiles:insertAttribute name="footer" />
				</td>
			</tr>
		</table>
	</body>
</html>
</i>

but I think the server can't find the xmlns. This is how the source looks in the browser:


<i><!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" xmlns:spring="http://www.springframework.org/tags">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title><tiles:insertAttribute name="title" ignore="true"></tiles:insertAttribute></title>
		<link rel="stylesheet" type="text/css" media="all" href="/jukemais/css/style.css" />
	</head>
	<body>
		<table border="1" cellpadding="2" cellspacing="2" align="center">
			<tr>
				<td height="30" colspan="2" rowspan="1"><tiles:insertAttribute name="header"></tiles:insertAttribute>
				</td>
			</tr>
			<tr>
				<td height="250" rowspan="1" colspan="1"><tiles:insertAttribute name="menu"></tiles:insertAttribute></td>
				<td width="350" rowspan="1" colspan="1"><tiles:insertAttribute name="body"></tiles:insertAttribute></td>
			</tr>
			<tr>
				<td height="30" colspan="2" rowspan="1"><tiles:insertAttribute name="footer"></tiles:insertAttribute>
				</td>
			</tr>
		</table>
	</body>
</html>
</i>


Any suggestion? Maybe it's not related to Thymeleaf... or maybe it is... :)

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: XML namespace

danielfernandez
Administrator
Hi,

If the code you are copying above is a thymeleaf template, and not a JSP page, your problem is that you are trying to use JSP tags in a Thymeleaf template.

You have several uses of:

    <tiles:insertAttribute .../>

...which is in fact a JSP tag. The thymeleaf-extras-tiles2 dialect allows you to use attributes like "tiles:include", which you can use like:

    <div tiles:include="myattribute">...</div>

Have a look at the README with code samples here: https://github.com/thymeleaf/thymeleaf-extras-tiles2

Regards,
Daniel