简体   繁体   English

javax.faces.STATE_SAVING_METHOD可序列化

[英]javax.faces.STATE_SAVING_METHOD Serializable

I have a JSF and Spring integrated application. 我有一个JSF和Spring集成的应用程序。 My Account Backing Bean class is with scope session and it is Serializable [as suggested here] . 我的Account Backing Bean类与作用域会话一起使用,并且可序列化(如此处建议 In my web.xml javax.faces.STATE_SAVING_METHOD value is 'server'. 在我的web.xml中,javax.faces.STATE_SAVING_METHOD的值为“服务器”。 Everything works good still here. 这里一切都很好。

[I have Backing bean, Service class and DAO class in layers.] [我在层中有Backing bean,Service类和DAO类。]

When I change the value of javax.faces.STATE_SAVING_METHOD to 'client' the application throws exception 'java.io.NotSerializableException' pointing to my service class. 当我将javax.faces.STATE_SAVING_METHOD的值更改为“ client”时,应用程序将抛出异​​常“ java.io.NotSerializableException”,指向我的服务类。 If I make the service class Serializable then the 'java.io.NotSerializableException' points to my DAO class. 如果我使服务类可序列化,则“ java.io.NotSerializableException”指向我的DAO类。 If I make the DAO class Serializable the application will work without issues. 如果我使DAO类可序列化,则该应用程序将正常运行。

However I think making the service class and DAO class Serializable is a not a good approach. 但是,我认为使服务类和DAO类可序列化不是一个好方法。

Looking for expert opinion. 寻找专家意见。

Thanks in advance. 提前致谢。

You should mark your service as transient in your account backing bean. 您应该在帐户支持bean中将您的服务标记为临时服务。 This prevents serialization. 这样可以防止序列化。

Example: 例:

@RequestScoped
public class AccountBackingBean {

 @EJB
 private transient MyService myService;
 private String someValue;

}

See also: 也可以看看:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM