未在@RequestScoped ManagedBean 中获取请求参数

Not getting request parameters in @RequestScoped ManagedBean

我有一个 JSF 页面并有一个与之关联的 Managedbean。

我的 xhtml 页面如下所示:

<h:head>

</h:head>

<h:body id="configuratorWrapper">
<h:form method="post" id="form" name ="name" prependId="false">
    <f:view>
        <div class="container">
        <input type="hidden" name="exception" id="exception" value="aaa" /> 
        </div>  
         <h:input type="hidden" name="email" id="email" value="#{emailManagedBean.sendEmailForErrorPage()}" /> 
    </f:view>
</h:form>
<h:outputScript library="resources/bower_components/boostrap-sass/assets/javascripts" name="bootstrap.js"></h:outputScript>
</h:body>

emailManagedBean 是关联的 Managedbean,它是一个 @RequestScoped ManagedBean。

EmailManagebean 中的方法 sendEmailForErrorPage() 如下所示:

public Boolean sendEmailForErrorPage() {
        this.exception = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("exception");
    }

我需要获取异常值 "aaa",这是我在 xhtml 页面中提供的。但是我现在得到的值是 null。

我尝试使用

<p:commandButton name ='email' action="#{emailManagedBean.sendEmailForErrorPage()}">
    <f:param name="exception" value="aaa" />
</p:commandButton>

结果仍然为空。

谁能帮我解决这个问题。

我找到了解决此问题的方法。我没有将它作为参数传递,而是作为参数传递给方法。它工作得很好。我能够获得异常值。

<f:event type="preRenderView" listener="#{emailManagedBean.sendEmailForErrorPage('aaa')}" />