Spring
Spring DAO
테라시아
2024. 12. 18. 19:05
☆ Code
★ TimeDAO.java
import java.util.Random;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.koreait.board.mapper.TimeMapper;
public class TimeDAO {
@Autowired
private TimeMapper mapper;
public String getTime() {
Random rd = new Random();
int num = rd.nextInt(2);
if(num == 0) {
return mapper.getTime1();
}
else {
return mapper.getTime2();
}
}
}
★ subjectVO.html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>시험결과</title>
</head>
<body>
<h1>시험결과([[*{tm}]])</h1>
<hr>
<table border="1" th:object="${vo}">
<tr><td>국어</td><td th:text="*{kor}"></td></tr>
<tr><td>영어</td><td th:text="*{eng}"></td></tr>
<tr><td>수학</td><td th:text="*{math}"></td></tr>
<tr><td>합계</td><td th:text="*{sum}"></td></tr>
<tr><td>평균</td><td th:text="*{avg}"></td></tr>
</table>
</body>
</html>