【问题标题】:JavaServer faces redirecting formJavaServer 面临重定向表单
【发布时间】:2014-03-06 11:25:13
【问题描述】:

你好,我有那个表格:

        <h:form>
            <h:selectOneRadio layout="pageDirection" value="#{votesBean.answer}">
                <f:converter converterId="PollConverter"/>
                <f:selectItems value="#{pollsBean.selectItems}"/>
            </h:selectOneRadio>
            <h:messages/>
            <h:commandButton value="#{msgs.vote}" action="/profile/main.xhtml"/>
        </h:form>

但是当我提交这个表单时,页面没有重定向到main.xhtml,而是刷新当前页面(viewpoll.xhtml,我认为是因为表单有错误),但不包含视图参数。我使用 view 参数来了解当前的民意调查……结果我得到空指针异常,因为我没有民意调查 id。

【问题讨论】:

    标签: forms jsf redirect


    【解决方案1】:
    • 如果您想直接导航而不进行验证和转换,请在h:commandButton 中使用immediate="true"。
    • 否则,Request Processing Life Cycle 可能会出现故障,例如。 validation phase。
    • 最后,你的URL(/profile/main.xhtml) 地址不正确。

    【讨论】:

      猜你喜欢
      • 2012-07-17
      • 2011-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-17
      • 2012-08-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多