Backing beans (@ManagedBean) or CDI Beans (@Named)?

后端 未结 5 1801
南旧
南旧 2020-11-22 00:33

I\'ve just started reading through Core JavaServer Faces, 3rd Ed. and they say this (emphasis mine):

It is a historical accident that there are two se

5条回答
  •  难免孤独
    2020-11-22 00:58

    With Java EE 6 and CDI you have different option for Managed Beans

    • @javax.faces.bean.ManagedBean is refer to JSR 314 and was introduced with JSF 2.0. The main goal was to avoid the configuration in the faces-config.xml file to use the bean inside an JSF Page.
    • @javax.annotation.ManagedBean(“myBean”) is defined by JSR 316. It generalizes the JSF managed beans for use elsewhere in Java EE
    • @javax.inject.Named(“myBean”) are almost the same, as that one above, except you need a beans.xml file in the web/WEB-INF Folder to activate CDI.

提交回复
热议问题