백엔드/spring

JSP에서 properties 값 사용하기

첸첸 2022. 3. 28. 13:37
728x90

1. util 등록

- 나는 context-properties.xml이라는 파일에 등록 해주었다. 

<util:properties id="사용할 아이디" location="propery경로/property이름"/>

#예
<util:properties id="myProp" location="classpath:egovframework/egovProps/globals.properties"/>

2. JSP에서 사용

- websocketUrl이라는 변수로 사용 가능

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<spring:eval expression="@myProp['websocket.url']" var="websocketUrl"/>
<spring:eval expression="@property 아이디['설정값']" var="jsp에서 사용할 변수명"/>
console.log("${websocketUrl}");