问题描述
我正在阅读 JSF MVC框架中的MVC是什么组件? /a>
I am reading What components are MVC in JSF MVC framework?
M -业务域/服务层(例如EJB/JPA/DAO)
V -您的JSF代码
C -FacesServlet
M - Business domain/Service layer (e.g. EJB/JPA/DAO)
V - Your JSF code
C - FacesServlet
在开发人员图中,体系结构 V 可被划分 如下:
In the developer picture, the architectural V is in turn dividable as below:
M -实体
V -Facelets/JSP页面
C -托管Bean
M - Entity
V - Facelets/JSP page
C - Managed bean
大写来说,JavaBean是一个模型.
On the upper case, the JavaBean is a model.
但是在小写的情况下,受管bean成为了控制器?
But on the lower case, the Managed bean becomes a controller?
他们不是同一个人吗?有什么区别?
They are not the same thing? What are the difference?
推荐答案
简短答案:托管Bean"是JSF托管Bean的旧式简称.这是由JSF管理的Java Bean.
Short answer : 'Managed Bean' is a legacy short name for JSF managed bean. It's a Java Bean managed by JSF.
长期:
bean通常是由容器管理的POJO(普通的旧Java对象).
A bean is typically a POJO (plain old java object) managed by a container.
在这里,托管表示由容器处理创建/销毁,实例数,实例范围和某些特定方法的调用.
Managed means here that the creation / destruction, the number of instances, their scope and the invocation of some specific method are handled by the container.
容器通常由基础服务器提供.在Java EE中,您具有不同的容器(CDI,EJB,Web等)
Containers are generally provided by the underlying server. In Java EE you have different container (CDI, EJB, Web, etc...)
JSF受管Bean由JSF容器管理Bean,EJB由EJB容器管理,Servlet/过滤器由Servlet容器管理,JPA实体由EntityManager等.
JSF Managed Bean are bean managed by JSF container, EJB are managed by EJB Container, Servlet / filters by the servlet container, JPA entities by the EntityManager, etc.
例如,在雄猫服务器上,您只有Web(servlet)容器,而没有EJB容器.如果使用JSF(必须提供关联的依赖项),那么您还将拥有托管bean.
For example, on a tomcat server, you have only web (servlet) container and not EJB one. If you use JSF (you must provide associated dependency) you will have managed beans as well.
这篇关于JavaBean和ManagedBean有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!