没有JSF的Facelets [英] Facelets without JSF

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

问题描述

我正在学习Java语言并期待编写非常小的Web应用程序,因为Facelets似乎是JSP的替代品,并且JSF对于小型Web应用程序来说似乎有些过分,我是否可以学习Facelets并在没有它的情况下使用它整个JSF堆栈?或者我应该使用JSP来获取这些小型网络应用程序?

I'm finishing on learning the Java language and looking to write very small web applications, since Facelets seems to be the replacement for JSP, and JSF seems overkill for small web apps, can I just learn Facelets and use it without the whole JSF stack? or should I just go with JSP for this small web apps?

推荐答案

可以使用JSF。只需在 web.xml中的 *。xhtml 的URL模式上映射 FacesServlet 并执行声明

It can be used without JSF. Just map the FacesServlet on an URL pattern of *.xhtml in web.xml and do not declare

xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"

任何Facelet模板中的

。声明它们实际上并没有坏处,但这样你就不会意外地使用它们。您可以在其中编写纯HTML,并将表单提交给普通的servlet,并将servlet转发/重定向到Facelet。

in any Facelet template. It actually don't harm to declare them, but this way you won't "accidentally" use them. You can as good write plain HTML in it and submit the form to a plain servlet and have the servlet forward/redirect to a Facelet.

您只需记住,使用servlet,您最终会获得更多样板代码,用于收集请求参数,转换/验证它们,维护和更新模型值,调用业务操作,而所有这些重复的样板代码对于一个完整的JSF托管bean是不必要的。

You only need to keep in mind that with a servlet you end up with much more boilerplate code for gathering the request parameters, converting/validating them, maintaining and updating the model values, invoking the business actions, while all this repeated boilerplate code is unnecessary with a fullworthy JSF managed bean.

此外,您不能将Facelets与基于请求的MVC框架一起使用其中只有JSP标记库可用,如Struts,Spring MVC等。

Also, you can't use Facelets with request based MVC frameworks which have only JSP taglibs available, like Struts, Spring MVC, etc.

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

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