java.lang.StringIndexOutOfBoundsException:字符串索引超出范围:-1在com.sun.faces.renderkit.ServerSideStateHelper.getState

时间:2012-08-05 09:36:59

标签: jsf indexoutofboundsexception state-saving

当我使用不带<p:tab>的代码时,它按预期工作,

<h:form>
    <p:wizard>
        <p:tab title="Test-1">
            <h:form>
                <p:growl id="msg"/>
                <p:selectOneMenu value="#{studentController.departmentIDgenerate}">
                    <f:selectItems value="#{departmentController.departmentList}" var="deparet" itemLabel="#{deparet.departmentName}" itemValue="#{deparet.departmentId}"/>
                    <p:ajax listener="#{studentController.addMessage}" update="msg"/>
                </p:selectOneMenu>            
            </h:form>
        </p:tab>
        <p:tab title="Test-2">
        </p:tab>
    </p:wizard>
</h:form>

但是当我开始使用<p:tab>时,它会引发以下异常:

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.substring(String.java:1937)
    at com.sun.faces.renderkit.ServerSideStateHelper.getState(ServerSideStateHelper.java:266)
    at com.sun.faces.renderkit.ResponseStateManagerImpl.getState(ResponseStateManagerImpl.java:100)

这是如何引起的?如何解决?

1 个答案:

答案 0 :(得分:2)

让我们先删除外部h:form(包装<p:wizard>的表单),因为这里有一个嵌套表单(这很糟糕)