새소식

반응형
Java/Spring

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

  • -
반응형

<util:properties id="" location="" />

<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']" />

 

반응형

'Java > Spring' 카테고리의 다른 글

@configurationProperties  (0) 2022.05.03
HikariCP  (0) 2022.05.03
Dynamic Web Project 만들기 2 - 프로젝트 기본 설정(1)  (0) 2022.05.01
Spring Context  (0) 2022.04.29
템플릿 엔진(Template Engine)  (0) 2022.04.28
Contents

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

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