此代码总是抛出 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/