有哪些Java库可用于生成HTML5?
我们的测试工具需要生成HTML标签(用于img,table,br,audio,video ..)以测试某个模块。 我们正在寻找可以生成符合HTML5标准的代码的java库。
有一个线程已经讨论过这个,但不确定它们是否支持HTML5
有几种可用:
- jwebutils
- 夏季
- jsoup
- itextpdf(我不确定他们支持哪些HTML)
Asual发布的Summer库支持Html5。
http://www.asual.com/blog/summer/2010/10/01/introducing-summer-the-html5-library-for-java.html
他们说没有太多文档……所以在Java编程社区被广泛接受之前,实现可能不会很好。
看看j2html , webfirmframework (我最 喜欢的 )。 如果你谷歌有很多你会得到很多开源库。
webfirmframework的示例代码:
NoTag noTag = new NoTag(null) {{ new Img(this, new Src("http://sofzh.miximages.com/java/pic_mountain.jpg"), new Alt("Mountain View"), new Style("width:304px;height:228px;")); new Br(this); new Audio(this, new Controls()) {{ new Source(this, new Src("horse.ogg"), new Type("audio/ogg")); new Source(this, new Src("horse.mp3"), new Type("audio/mpeg")); new NoTag(this, " Your browser does not support the audio element. "); }}; }}; System.out.println(noTag.toHtmlString());
版画
j2html示例代码:
body( h1("Heading!").withClass("example"), img().withSrc("https://stackoverflow.com/questions/3879501/what-kind-of-java-libraries-are-available-for-generating-html5/img/hello.png") ).render();
变
Heading!