问题
I am reading What components are MVC in JSF MVC framework?
In the big architectural picture, your own JSF code is the V:
M - Business domain/Service layer (e.g. EJB/JPA/DAO)
V - Your JSF code
C - FacesServletIn the developer picture, the architectural V is in turn dividable as below:
M - Entity
V - Facelets/JSP page
C - Managed bean
On the upper case, the JavaBean is a model.
But on the lower case, the Managed bean becomes a controller?
They are not the same thing? What are the difference?
回答1:
Short answer : 'Managed Bean' is a legacy short name for JSF managed bean. It's a Java Bean managed by JSF.
Long one :
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.
Containers are generally provided by the underlying server. In Java EE you have different container (CDI, EJB, Web, etc...)
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.
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.
来源:https://stackoverflow.com/questions/16978886/what-is-difference-between-javabean-and-managedbean