jsp에서 properties 파일의 값을 표시하기 원할때가 있음.
jsp 에서 바로 호출하여 표시할 수가 있음.
config.properites 파일 내용
devmode=[dev]
스프링 xml 에 property-placeholder 를 정의한다.
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
<context:annotation-config/>
<!-- 프로퍼티 파일을 가져온다. -->
<util:properties id="config" location="classpath:config.properties" />
<context:property-placeholder properties-ref="config" />
.....
JSP에 taglib 추가 및 <spring> tag 로 값을 가져온다.
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<html>
<head>
<title><spring:eval expression="@config.getProperty('devmode')" /></title>
</head>
<body>
</body>
</html>