简体   繁体   中英

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">

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

<!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, eg

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

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM