Java EE 6:JSF与Servlet + JSP。我应该学习JSF吗? [英] Java EE 6: JSF vs Servlet + JSP. Should I bother learning JSF?

查看:151
本文介绍了Java EE 6:JSF与Servlet + JSP。我应该学习JSF吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过阅读来熟悉Java EE 6 http://java.sun.com/javaee/6/docs/tutorial/doc/gexaf.html 。我对JSF的使用有点困惑。

通常,我开发Web App的方式是,Servlet就像一个控制器,JSP就像一个MVC模型中的View。那么JSF是否试图取代这种结构?以下是上述教程的引用:

I am trying to get familiar with Java EE 6 by reading http://java.sun.com/javaee/6/docs/tutorial/doc/gexaf.html. I am a bit confused about the use of JSF.
Usually, the way I develop my Web App would be, Servlet would act like a controller and JSP would act like a View in an MVC model. So Does JSF try to replace this structure? Below are the quote from the above tutorial:


Servlet最适合面向服务的应用程序和面向表示的应用程序的控制功能,如调度请求

JSF和Facelet更适用于生成标记,如XHTML,通常用于面向演示的应用

Servlet are best suited for service-oriented App and control function of presentation-oriented App like dispatching request
JSF and Facelet are more appropriated for generating mark-up like XHTML, and generally used for presentation-oriented App

我不确定我是否理解上述引用,他们没有解释什么是面向服务与面向演示。

Not sure if I understand the above quote too well, they did not explain too well what is service-oriented vs presentation-oriented.


JavaServer Faces应用程序可以将HTTP请求映射到特定于组件的事件处理,并将组件作为服务器上的有状态对象进行管理。

A JavaServer Faces application can map HTTP requests to component-specific event handling and manage components as stateful objects on the server.

任意知识渊博的Java开发人员可以给我一个关于JSF,JSP和Servlet的快速概述吗?我是否将它们全部集成在一起,还是在应用程序中将它们分开使用?如果是这样那么什么样的应用程序使用JSF与Servlet和JSP相比

Any knowledgeable Java developer out there can give me a quick overview about JSF, JSP and Servlet? Do I integrate them all, or do I use them separated base on the App? if so then what kind of app use JSF in contrast with Servlet and JSP


JavaServer Faces应用程序可以将HTTP请求映射到特定于组件的事件处理和管理组件作为服务器上的有状态对象。

A JavaServer Faces application can map HTTP requests to component-specific event handling and manage components as stateful objects on the server.

听起来像servlet可以做什么,但不确定将组件作为服务器上的有状态对象进行管理。甚至不确定这是什么意思?在此先感谢。

Sound like what servlet can do, but not sure about manage components as stateful objects on the server. Not even sure what that mean? Thanks in advance.

推荐答案

JSF基本上使您能够开发仅包含模型对象(JavaBeans)和视图的Web应用程序(JSP / XHTML页面)。使用普通的vanillaJSP / Servlet,您必须引入大量代码来控制,预处理,后处理,收集数据,验证,转换,监听等HTTP请求和响应。然后我不是在谈论将它重构为高(抽象)程度,这样你也可以像JSF一样(每个用例只是一个JavaBean类和一个JSP / XHTML页面)。

JSF basically enables you to develop a web application with only model objects (JavaBeans) and views (JSP/XHTML pages). With "plain vanilla" JSP/Servlet you'll have to bring in a lot of code to control, preprocess, postprocess, gather data, validate, convert, listen, etc the HTTP request and response. And then I'm not talking about refactoring it to a high (abstract) degree so that you can also end up the same way as JSF does (just a JavaBean class and a JSP/XHTML page per use case).

我在此之前就这个主题发布了更详细的答案: JSF,Servlet和JSP之间有什么区别?

I've posted a more detailed answer on the subject before here: What is the difference between JSF, Servlet and JSP?

这篇关于Java EE 6:JSF与Servlet + JSP。我应该学习JSF吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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