• 데이터베이스에서 가져온 책소개 정보가 너무 길어서 JSP에서 글자수를 줄여줌.

  • 평점 데이터(소수점 포함)를 아이콘으로 표시하기 위해 내림 작업을 Function 태그를 이용해 처리함.

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="bit.hibooks.setting.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

// 글자수 줄이기
<c:choose>
	<c:when test="${fn:length(book.b_desc) gt 451}">
		${fn:substring(book.b_desc, 0, 451)}...
	</c:when>
	<c:otherwise>
		${book.b_desc}
		<c:forEach begin="0" end="${(451- fn:length(book.b_desc)) / 52 + 1}"><br></c:forEach>
	</c:otherwise>
</c:choose>

// 평점을 아이콘으로 나타내기
<c:forEach begin="1" end="${book.b_rate-(book.b_rate%1)}">
	<i class="fa fa-star" style="color: red;"> </i>
</c:forEach>
<c:forEach begin="${book.b_rate-(book.b_rate%1)+1}" end="5">
	<i class="far fa-star"> </i>
</c:forEach>
profile
객체와 제어, 비전공자 개발자 되기

0개의 댓글