Dev
JSP 파일에서 프로퍼티 사용하기
얼그레이퀸아망
2017. 7. 18. 15:50
728x90
PropertyPlaceholderConfigurer
can only parse placeholders in Spring configuration (XML or annotations). Is very common in Spring applications use a Properties
bean. You can access it from your view this way (assuming you are using InternalResourceViewResolver
):
<bean id="properties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list><value>classpath:config.properties</value></list>
</property>
</bean>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
<property name="exposedContextBeanNames">
<list><value>properties</value></list>
</property>
</bean>
Then, in your JSP, you can use ${properties.myProperty}
or ${properties['my.property']}
.
출처
https://stackoverflow.com/questions/3933862/how-to-use-property-from-property-file-specified-in-propertyplaceholderconfigure