Passing init params to Manage bean

后端 未结 2 1209
囚心锁ツ
囚心锁ツ 2021-01-16 13:15

I have a authorization managed bean to fetch restriction rules to be applied to the tags within every jsf of the application. The managed bean requires to know the name of t

相关标签:
2条回答
  • 2021-01-16 13:31

    You can get init-params defined in web.xml by:

    FacesContext.getCurrentInstance().getExternalContext()
        .getInitParameter("paramName");
    
    0 讨论(0)
  • 2021-01-16 13:52

    Declare it in web.xml as follows:

    <context-param>
        <param-name>paramName</param-name>
        <param-value>PARAM_VALUE</param-value>
    </context-param>
    

    Access it in ManagedBean as follows:

    FacesContext.getCurrentInstance()
                    .getExternalContext().getInitParameter("paramName")
    

    Hope this helps to solve your problem.

    0 讨论(0)
提交回复
热议问题