티스토리 뷰

원문 : http://umsh86.tistory.com/category/spring


1. 설정 값이 들어 있는 xml  파일. 이 문서에서는 mobileWeb-properties.xml 파일.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd" >

<properties>
  <comment>comment here</comment>
  <entry key="TestMessage">이 값은 mobileWeb-properties.xml 에 들어 있는 값 입니다.</entry>
</properties>



2. beans가 등록된 xml 파일. 이 문서에서는 mobileWeb-servlet.xml 파일.

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
                      ...중략...
              xmlns:util="http://www.springframework.org/schema/util"
              xsi:schemaLocation="http://www.springframework.org/schema/beans"
                      ...중략...
              http://www.springframework.org/schema/util
            http://www.springframework.org/schema/util/spring-util.xsd"
             >

<!-- 설정값이 들어 있는 xml 파일  -->
<util:properties id="config" location="/WEB-INF/config/mobileWeb-properties.xml"></util:properties>



3. xml 문서에서 값을 가져다 쓰기.

   <property name="myValue" value="#{config['TestMessage']}">
       ... 중략 ...
   </property>



4. jsp 에서 값을 가져다 쓰기.

<!-- xml의 설정 값을 읽어 오기 위한 부분 -->
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
    ... 중략 ...
<body>
    ... 중략 ...
 <spring:eval expression="@config['TestMessage']"></spring:eval><br>
</body>



5. SpEL을 이용해서 Java에서 사용하는 방법.

@Value("#{config['TestMessage']}") String TestMessage;


댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함