새소식

반응형
Java/Spring

<util:properties> 태그를 이용한 Context 파일에 프로퍼티 등록

  • -
반응형

<util:properties> 태그를 이용하여 Context 파일에 프로퍼티를 등록하여 Java나 JSP 파일에서 호출하여 사용할 수 있다.

 

<util:properties id="프로퍼티 ID(식별값)" location="프로퍼티 파일 위치/프로퍼티 파일명" />

 

예)

RootApplicationContext인 root-context.xml 파일

- root-context.xml

// root-context.xml 파일 내 설정
<util:properties id="config" location="classpath:/context/web.properties" />

- src/main/resources/context/web.properties

// src/main/resources/context/web.properties
user.name=obo

 

- Java 파일 내 사용

@Value("#{config['user.name']}")

 

- JSP 파일 내 사용

<spring:eval expression="@config['user.name']" />

 

반응형
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.