๐Ÿ’ป

JSP ํ”„๋กœ๊ทธ๋ž˜๋ฐ - [JSTL] functions ๋ณธ๋ฌธ

KITRI/JSP

JSP ํ”„๋กœ๊ทธ๋ž˜๋ฐ - [JSTL] functions

๋˜ํšจ๋‹ˆ 2020. 6. 29. 14:52

function tags

 

ํ‘œ์ค€ ํ•จ์ˆ˜๋ฅผ ์ œ๊ณตํ•œ๋‹ค. ๋Œ€๋ถ€๋ถ„์€ ์ผ๋ฐ˜์ ์œผ๋กœ ๋ฌธ์ž์—ด ์กฐ์ž‘์„ ์œ„ํ•œ ํ•จ์ˆ˜์ด๋‹ค. 

 

<%@ taglib  prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

 

 

 

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<c:set var="str1" value="Function ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค."/>
	<c:set var="str2" value="์‚ฌ์šฉ"/>
	<c:set var="str3" value="1,2,3,4,5,6,7,8,9,10"/>
	
	<h3>${str1}</h3>
	<h3><c:out value="${str2}"/></h3>
	<h3>${str3}</h3>
	<br /><br />
	
	<div>
		1. ๋ฌธ์ž์—ด๊ธธ์ด: ${fn:length(str1)} <br />
		2. ๋Œ€๋ฌธ์ž: ${fn:toUpperCase(str1)} <br />
		3. ์†Œ๋ฌธ์ž: ${fn:toLowerCase(str1)} <br />
		4. ๋ฌธ์ž์—ด์ถ”์ถœ: ${fn:substring(str1,3,6)} <br />
		5. ๋ฌธ์ž์—ด์น˜ํ™˜: ${fn:replace(str1, " ", "-")} <br />
		6. ๋ฌธ์ž์—ด์œ„์น˜: ${fn:indexOf(str1, "t")} <br />
		
		7. ๋ฌธ์ž์—ด1์—์„œ ๋ฌธ์ž์—ด2์— ํฌํ•จ๋˜์–ด ์žˆ๋Š” ๋ฌธ์ž์—ด ์ดํ›„: ${fn:substringAfter(str1, str2)}<br />
		8. ๋ฌธ์ž์—ด1์—์„œ ๋ฌธ์ž์—ด2์— ํฌํ•จ๋˜์–ด ์žˆ๋Š” ๋ฌธ์ž์—ด ์ด์ „: ${fn:substringBefore(str1, str2)}<br />
		9. ์‹œ์ž‘๋ฌธ์ž์—ด: ${fn:startsWith(str1, 'Fun')}<br />
		10. ๋๋ฌธ์ž์—ด:${fn:endsWith(str1,'์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.')} <br/>
		11. ๋‘๋ฌธ์ž์—ด๊ธธ์ด ํฌํ•จ: ${fn:contains(str1, str2)} <br />
		12. ๋‘๋ฌธ์ž์—ด ํฌํ•จ(๋Œ€์†Œ๋ฌธ์ž๊ตฌ๋ถ„์•ˆํ•จ): ${fn:containsIgnoreCase(str1,str2)}<br/>
		
		๋ฌธ์ž์—ด ๋ถ„๋ฆฌํ•ด์„œ ๋ฐฐ์—ด๋กœ ๋ฐ˜ํ™˜
		<c:set var="array" value="${fn:split(str3, ',')}"/>
		<c:forEach var="i" items="array">
			${i}
		</c:forEach> <br />
		
		๋ฌธ์ž์—ด ํ•ฉ์น˜๊ธฐ
		${fn:join(array,"*")}
	</div>
</body>
</html>

๋ฐ˜์‘ํ˜•
Comments