0
在我的應用程序中,我希望在應用程序啓動時存儲列表數據,並且我希望在需要時在jsp頁面上獲取它。爲此,我已經定義bean
如下從春季會話中無法顯示jsp上的列表
<beans:bean id="systemService" class="com.mycompany.System" init-method="setMasterList" lazy-init="false"/>
component
如下
@Controller
@Component("system")
@Scope(WebApplicationContext.SCOPE_GLOBAL_SESSION)
public class System
{
public Map<Integer, String> masterList = new HashMap<Integer, String>();
public Map<Integer, String> populateMasterList()
{
masterList.put(1, "About US");
masterList.put(2, "About US");
return masterList;
}
public Map<Integer, String> getMasterList()
{
return masterList;
}
public void setMasterList()
{
this.masterList = populateMasterList();
}
}
我試圖找回在JSP中主列表。我試圖訪問它在jsp上如下
Master : ${system.masterList}
但在jsp上顯示爲空白。我也嘗試使用Scope作爲@Scope(WebApplicationContext.SCOPE_SESSION)
。但不能成功。
我嘗試過,但它不工作。 – Abhijit
日誌在加載應用程序上下文時會說些什麼?它是否包含有關systemService bean的所有內容? – user2953113
沒有。我試圖調試它。它執行得很好。 – Abhijit