1. create a bean to implements the ServletContextAware, and spring will automatically set the servletContext:

public class ApplicationScopeObjectSettings implements ServletContextAware {
ServletContext servletContext;

public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
servletContext.setAttribute("appScope", "appScope" + (new java.util.Date()));

}
}


2. in xml file:
<bean id="ApplicationScopeObjectSettings" class="ApplicationScopeObjectSettings"/>

3. Then you can access the appScope in application scope in your jsp
page.
评论
发表评论

提醒: 该博客已发表在公共论坛,博客所有留言会成为论坛回贴,留言请注意遵守论坛发贴规则

您还没有登录,请登录后发表评论