Facelets页面是否像JSP生成给Servlet那样生成给Servlet [英] Is Facelets page generated to Servlet as JSP generated to Servlet

查看:18
本文介绍了Facelets页面是否像JSP生成给Servlet那样生成给Servlet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于所有 JSP 在执行之前都会生成/转换为 Servlet,因此对于 Facelets 也是如此吗?

As all JSPs are generated / translated to Servlets before their execution, is its true for Facelets too?

我正在使用 JSF 2.0 和 Facelets,并希望查看其生成的 Java 代码(可能是 Servlet).

I am working with JSF 2.0 and Facelets and wanted to see its generated Java Code which might be Servlet.

推荐答案

不,Facelets 文件使用 SAX 解析器.XML 树存储在 Facelet 缓存.XML 树在 视图构建时间变成了UIComponent 树,可通过 FacesContext#getViewRoot()(你可以通过 getChildren() 在运行时).组件树通常通过它们自己的 encodeXxx() 方法或关联的 Renderer,以 UIViewRoot#encodeAll().

No, Facelets files are parsed to a XML tree using a SAX parser. The XML tree is stored in the Facelet cache. The XML tree is during view build time turned into an UIComponent tree which is accessible by FacesContext#getViewRoot() (which you can traverse by getChildren() during runtime). The component tree normally generates HTML code by their own encodeXxx() methods or the ones on the associated Renderer, starting with UIViewRoot#encodeAll().

Facelets 文件生成任何类文件.XML 树默认存储在服务器的内存中.但是,从 JSF 2.1 开始,您可以指定自定义 FaceletCachefaces-config.xml 中实现,您可以在其中编写代码来存储 XML 树例如在磁盘文件系统上(虽然会更慢).

Facelets files do not generate any class files. The XML trees are by default stored in server's memory. Since JSF 2.1 you can however specify a custom FaceletCache implementation by <facelet-cache-factory> in faces-config.xml wherein you can write code to store the XML tree on for example the disk file system (which would be slower, though).

如果你在视图中使用并打开它,那么你可以看到UIViewRoot后面的组件树的文本表示.另请参阅如何调试 JSF/EL

If you use <ui:debug> in the view and open it, then you can see the textual representation of the component tree behind UIViewRoot. See also how to debug JSF/EL

这篇关于Facelets页面是否像JSP生成给Servlet那样生成给Servlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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