有时我在部署项目时遇到错误,但每次都没有。错误
时,Localbean不起作用错误消息
Warning: JSF1063: WARNING! Setting non-serializable attribute value into HttpSession (key: localBean, value class: LocalBean).
Localbean
package com.mycompany.crm;
import java.io.Serializable;
import java.util.Locale;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
@ManagedBean
@SessionScoped
public class LocalBean implements Serializable{
public Locale locale;
@PostConstruct
public void init() {
locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
}
public Locale getLocale() {
return locale;
}
public String getLanguage() {
return locale.getLanguage();
}
public void setLanguage(String language) {
locale = new Locale(language);
FacesContext.getCurrentInstance().getViewRoot().setLocale(locale);
}
}
答案 0 :(得分:0)
尝试在您的类中放置serialVersionUID字段,如:
private static final long serialVersionUID = -1;