public class SimpleSessionStatus implements SessionStatus {
private boolean complete = false;
@Override
public void setComplete() {
this.complete = true;
}
@Override
public boolean isComplete() {
return this.complete;
}
}
该类还有一个方法是isComplete将会在ModelFactory中的updateModel方法中调用,updateModel方法用于将@SessionAttributes中列出的model attributes推广到session中。
public void updateModel(NativeWebRequest request, ModelAndViewContainer container) throws Exception {
ModelMap defaultModel = container.getDefaultModel();
if (container.getSessionStatus().isComplete()){
this.sessionAttributesHandler.cleanupAttributes(request);
}
else {
this.sessionAttributesHandler.storeAttributes(request, defaultModel);
}
if (!container.isRequestHandled() && container.getModel() == defaultModel) {
updateBindingResult(request, defaultModel);
}
}
由于之前我们调用了setComplete方法,所以方法会进入if分支调用SessionAttributesHandler的cleanupAttributes方法。该方法用于将从session中移除已知的属性