我正在尝试在应用程序范围的托管bean中读取web.xml文件中的params。尝试获取facescontext时,返回null。有没有其他方法可以获取web xml中定义的所有参数列表?
<context-param>
<param-name>SOME_NAME</param-name>
<param-value>SOME_VALUE</param-value>
</context-param>
我的托管bean:
@ManagedBean
@ApplicationScoped
public class ConfigurationParameters implements Serializable {
private Map<String, Object> parameters;
@PostConstruct
public void init() {
final FacesContext facesContext = FacesContext.getCurrentInstance();
if(facesContext != null) { //this is always null
ExternalContext ctx = facesContext.getExternalContext();
parameters = ctx.getInitParameterMap();
}
}