1. 程式人生 > >Spring、SpringMVC取properties檔案的值

Spring、SpringMVC取properties檔案的值

之所以要這樣,是因為我們可以將一些將來可能變的資料抽取出來。

例如,檔案內容:

CART_COOKIE:CART_LIST
COOKIE_MAXAGE:3600

步驟:

1、配置檔案掃描該檔案:

<context:property-placeholder location="classpath:conf/cart.properties"/>
2、
@Value("${CART_COOKIE}")
	private String CART_COOKIE;