른록노트

[Spring] jstl c 태그에서 java method 사용하는 방법 본문

Web/[Spring]

[Spring] jstl c 태그에서 java method 사용하는 방법

른록 2022. 1. 12. 20:00

1. 요구사항

c태그로 데이터를 출력할 때 이미 만들어놓은 java method를 사용하고 싶습니다.

//result.money 값은 80000
//이미 만들어논 java Method를 이용해서 데이터를 변경하고싶음
<c:out value="${result.money}"/>
//결과는
//80000

//원하는 결과는
//com.common.Util 클래스의 makeComma(String data) method를 사용해서
//80,000로 출력하고싶음

2. 방법

jsp:useBean 태그를 사용해서 c 태그 안에서 method를 사용할 수 있습니다

<jsp:useBean id="util" class="com.common.Util"/>

<c:out value="${util.makeComma(result.money)}"/>

참고사이트

https://stackoverflow.com/questions/25198690/how-to-call-java-method-in-jstl

반응형
Comments