2008-05-03
Put objects into servlet context(applicationLevel)
关键字: spring
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.
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.
发表评论
提醒: 该博客已发表在公共论坛,博客所有留言会成为论坛回贴,留言请注意遵守论坛发贴规则







评论排行榜