在代码中使用

@Controller public class IndexController { @Value("${CONTENT_LUNBO_ID}") private Long CONTENT_LUNBO_ID; @Autowired private ContentService contentService; @RequestMapping("/index") public String showIndex(Model model) { //查询内容列表 List<TbContent> ad1List = contentService.getContentListByCid(CONTENT_LUNBO_ID); // 把结果传递给页面 model.addAttribute("ad1List", ad1List); return "index"; } }
.properties

CONTENT_LUNBO_ID=89
在springMVC中加载:
<!-- 加载配置文件 -->
<context:property-placeholder location="classpath:conf/resource.properties" />