Tom Tucker
Tom Tucker

Reputation: 11896

Tag Libraries for Spring MVC

I'm writing a web application using Spring MVC. Although Spring MVC comes with a couple of tag libraries, they are not rich as Struts' counterpart. What I miss most is <html:xhtml>.

Those of you using Spring MVC, what third-party tag libraries do you guys use?

Thanks!

Edit: More specifically, I would like to auto-generate the following using a custom tag.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

Upvotes: 4

Views: 2440

Answers (3)

cdeszaq
cdeszaq

Reputation: 31280

With HTML5's doctype being much more simple, all you need to have now for a doctype is <!doctype html> which is just as short, or shorter, than most tag libs, and also has much less overhead.

All you need now is:

<!doctype html>
<html>
</html>

The best solution, however, is still to put your basic boilerplate into an include file like @skaffman suggested. This lets you get the boilerplate nice and optimized and then you can keep using the same one and don't have to worry about it any more. The HTML5Boilerplate project is a good place to start for that.

Upvotes: 1

skaffman
skaffman

Reputation: 403451

If all you want to do is generate that fragment, then what's wrong with <jsp:include>, or a simple tagfile, e.g.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<jsp:doBody>
</html>

Stick that in /WEB-INF/tags/xhtml.tag, and you're done, e.g.

<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>

<tags:xhtml>
   // Rest of content in here
</tags:xhtml>

Upvotes: 2

skis
skis

Reputation: 71

You might want to try the spring's form taglib

"<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>"

it is html 4.01 and XHTML1.0 compliant.

Upvotes: 1

Related Questions