0
我正在開發一個使用Spring注入的系統。在某個點上,屏幕上會顯示一條警告,該警告使用一個名爲Spring Controller的WarningHelper類的屬性顯示。以下是總結代碼:春季控制器保持舊值
@Controller
@Scope(WebApplicationContext.SCOPE_SESSION)
public class WarningHelper implements Serializable {
//Bunch of attributes
private String warningText;
//Bunch of other methods
private String configureWarning(Integer caller, Outcome outcome, WarningReturn warningReturn, GlobalWebUser user) {
//business logic
if (hasWarning()) {
setWarningText(warningReturn.getWarningText());
}
return redirect;
}
}
該部分完美地工作。稍後,xhtml頁面會使用另一個控制器顯示此警告,其中第一個控制器將注入此警告。以下是第二個控制器的編輯代碼:
@Controller
@Scope(WebApplicationContext.SCOPE_APPLICATION)
public class CustomUrlController {
//Bunch of other attributes
@Inject
private WarningHelper warningHelper;
//Bunch of methods
public String getAllMessages() {
String completeMessage = "";
//business logic creating the message
completeMessage += warningHelper.getWarningText();
return complete Message
}
}
這一切都工作得很好,第一次。問題是,如果我嘗試輸入另一個具有不同消息的配置文件,則仍會顯示第一個配置文件。請注意,此更改過程不涉及其他登錄,因此會話仍然相同。我試圖繞過範圍,但無濟於事。
似乎它的工作。我會再測試一下,但初步測試很好!謝謝! –
歡迎您:) – Keerthivasan