java - @ViewScoped 在开发模式下工作,但在生产模式下不起作用

标签 java google-app-engine jsf-2

此代码总是抛出 ViewExpiredException

@ManagedBean(name = "test")
@ViewScoped
public class test implements Serializable{

    private int count;

    public int getCount() {
        return count;
    }

    public void increment() {
        count++;
    }
}

和xhtml:

<body>
    <h:form>
        <h:panelGrid columns="2" cellpadding="5">
            <h:outputText value="Counter: " />
            <h:outputText value="#{test.count}" />
        </h:panelGrid>
        <h:commandButton value="Count" action="#{test.increment}" update="@form" />
    </h:form>
</body>

有什么技巧吗? session 存储在服务器中

最佳答案

取决于您的GAE SDK版本...但至少对于旧版本,必须将javax.faces.STATE_SAVING_METHOD设置为client原因GAE不支持将其设置为 session

<context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
</context-param>

关于java - @ViewScoped 在开发模式下工作,但在生产模式下不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13819599/

相关文章:

python - 如何在不知道类名的情况下使用 NDB 查询

python - 应用引擎 : uncaught application failure

python - 由于 1.7.6 更新,我真的需要安装 Xcode 并编译 PyObjC 吗?

java - Primefaces p :datatable adding and editing rows not working

jsf - p :remoteCommand not working in async mode

Spring Boot JSF集成

java - 替换事务后使用嵌套 fragment 重用 fragment

java - R.java android studio 中 GradientColor_fontVariationSettings 的重复实例

java - 将 Java 字节数组转换为 iOS NSData

java - 使用继承时 Hibernate ManyToMany 不起作用