我遇到了一个与 Java 中 transient
关键字在 private
修饰符前使用有关的问题。
变量声明:
transient private ResourceBundle pageResourceBundle;
我的课堂看起来像这样:
public class LoginViewModel extends AbstractViewModel {
transient private ResourceBundle pageResourceBundle;
@AfterCompose
public void afterCompose(@ContextParam(ContextType.VIEW) Component view) {
initializeLoginValues();
boolean timeout = BooleanUtils.toBoolean(getHttpServletRequest().getParameter("timeout"));
if (timeout) {
Messagebox.show(pageResourceBundle.getText("MSG_SESSION_HAS_EXPIRED_PLEASE_LOGIN"), pageResourceBundle.getText("LABEL_ALERT"),
Messagebox.OK, Messagebox.ERROR);
}
view.getPage().setTitle(CsdcLicence.get().getApplicationName());
}
我有一些问题。
1.为什么要在私有变量前使用transient
关键字?
2.使用这个关键字的目的是什么?
transient
与模型一起用于其他目的。它可能会在视图中显示除了transient
字段之外的所有字段。你需要阅读你所使用的库的文档。 - Peter Lawrey