问题描述
我试图通过阅读。我对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:
我不确定我是否理解上述引用,他们没有解释什么是面向服务与面向演示。
Not sure if I understand the above quote too well, they did not explain too well what is service-oriented vs presentation-oriented.
任意知识渊博的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
听起来像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).
我在此之前就这个主题发布了更详细的答案:
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吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!