如何在JSF中减少javax.faces.ViewState [英] How to reduce javax.faces.ViewState in JSF
问题描述
减少JSF中viewstate隐藏字段大小的最佳方法是什么?
我注意到我的视图状态大约是40k,这会下降到客户端并在每次请求时返回服务器,特别是响应到服务器,这对用户来说是一个显着的减速。
What is the best way to reduce the size of the viewstate hidden field in JSF? I have noticed that my view state is approximately 40k this goes down to the client and back to the server on every request and response espically coming to the server this is a significant slowdown for the user.
我的环境JSF 1.2,MyFaces,Tomcat,Tomahawk,RichFaces
My Environment JSF 1.2, MyFaces, Tomcat, Tomahawk, RichFaces
推荐答案
您是否尝试过将状态保存设置为服务器?这应该只向客户端发送一个id,并保持服务器上的完整状态。只需将以下内容添加到文件 web.xml :
Have you tried setting the state saving to server? This should only send an id to the client, and keep the full state on the server. Simply add the following to the file web.xml :
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
这篇关于如何在JSF中减少javax.faces.ViewState的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!