java JSF 1.2 和 2.0 之间的主要区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7601033/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 20:38:35  来源:igfitidea点击:

Main differences between JSF 1.2 and 2.0

javajsf

提问by Nick H G

I am in need of getting up to speed with JSF 2.0. I have found a nice and practical tutorial at JSF tutorial. This tutorial covers creating JSF applications using JSPs (JSF 1.2). At our place we are using JSF 2.0 and building with Facelets. When studying a tutorial using JSPs what are the pitfalls and differences I need to be aware of when having to do things with Facelets ?

我需要跟上 JSF 2.0 的速度。我在JSF 教程中找到了一个不错的实用教程。本教程介绍了使用 JSP (JSF 1.2) 创建 JSF 应用程序。在我们这里,我们使用 JSF 2.0 并使用 Facelets 进行构建。在学习使用 JSP 的教程时,必须注意使用 Facelets 时需要注意的陷阱和差异是什么?

采纳答案by digitaljoel

The great thing about Facelets vs. JSP as a view technology for JSF is that facelets respect the entire jsf lifecycle whereas with JSP you have the two lifecycles competing (JSF vs. JSP).

Facelets 与 JSP 作为 JSF 的视图技术的伟大之处在于,facelets 尊重整个 jsf 生命周期,而对于 JSP,您有两个生命周期竞争(JSF 与 JSP)。

With JSP, you may be tempted to use other tag libraries (like JSTL) which may not behave as you are expecting due to the differences in the lifecycle. Some of the JSTL tags have been converted to facelet tags, but even then there are generally suitable pure JSF replacements for them (like ui:repeat in place of c:foreach)

对于 JSP,您可能会想使用其他标记库(如 JSTL),由于生命周期的差异,这些库的行为可能与您预期的不同。一些 JSTL 标记已转换为 facelet 标记,但即便如此,通常也有适合它们的纯 JSF 替代品(如 ui:repeat 代替 c:foreach)

If you are doing JSF 2.0, use facelets and you'll never look back.

如果您正在使用 JSF 2.0,请使用 facelets,您将永远不会回头。

回答by Thorbj?rn Ravn Andersen

Facelets are generally nice to work with.

Facelets 通常很适合使用。

The major difference in JSF 2.0 compared to earlier versions is that you can directly invoke Java methods easily from EL, making it much easier to do logic operations and information passing in the JSF snippets themselves.

与早期版本相比,JSF 2.0 的主要区别在于您可以轻松地直接从 EL 调用 Java 方法,从而更轻松地执行逻辑操作和在 JSF 片段本身中传递信息。