实现InitializingBean, ServletContextAware
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| @Service public class ConstanstMap implements InitializingBean, ServletContextAware {
public final static Map<String, String> initConfig = new HashMap<>();
@Resource private ContentVoMapper contentDao;
@Override public void afterPropertiesSet() throws Exception {
}
@Override public void setServletContext(ServletContext servletContext) { ContentVoExample contentVoExample = new ContentVoExample(); contentVoExample.createCriteria().andTypeEqualTo(Types.PAGE.getType()); List<ContentVo> contentVos = contentDao.selectByExampleWithBLOBs(contentVoExample); for (ContentVo contentVo : contentVos) { initConfig.put(contentVo.getSlug(),contentVo.getTitle());
} } }
|