JSF美化/美化HTML输出 [英] JSF prettify/beautify HTML output

查看:68
本文介绍了JSF美化/美化HTML输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在向用户发送JSF页面之前更正缩进,因为缩进与JSF有点杂乱,并且使用nicier缩进来做css stylig会更容易.因此,我想将JSF渲染编写的所有输出重定向到一个变量,解析它,然后将其发送给用户.我试着玩一些,并认为<f:phaseListener>收听RenderPhase可能是正确的方法,但我不知道具体如何做.

I want to correct indent before I send a JSF page to the user, because the indent is a little bit messy from JSF and it would be easier to do css stylig with nicier indent. So I want to redirect all output written by JSF rendering to a variable, parse it and then send it to the user. I tried to play a little with and thought that the <f:phaseListener> listening to RenderPhase might be the right way to go, but I don't know how to do that concretely.

推荐答案

A PhaseListener 仅在以下情况下很有趣您有兴趣在JSF生命周期和/或JSF组件树上进行拦截,而不是仅对它的生成的HTML响应感兴趣.存在 JTidyFilter 正是您想要的.只需在web.xml中定义一次,所有重新生成的HTML就会被美化.它基本上所做的只是包装response.getOutputStream()以首先通过 JTidy 拖拉它.

A Filter is the best tool for the job. A PhaseListener is only interesting if you're interested in intercepting on the JSF lifecycle and/or the JSF component tree, not when you're only interested in its generated HTML response. There exist the JTidyFilter which does exactly what you want. Just define it once in web.xml and all the respone HTML will be prettified. All it basically does is wrapping the response.getOutputStream() to haul it through JTidy first.

这篇关于JSF美化/美化HTML输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆