Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- javascripteverywhere
- 나는리뷰어다
- 테라폼
- 이벤트기반
- 플러터생존코딩
- 사용자유치
- 책프협
- 자바스크립트는모든곳에존재한다
- 리액트네이티브
- 파이토치
- 그로스 마케팅
- 텐서플로라이트
- 딥러닝
- 리눅스
- 머신러닝을 활용한 웹 최적화
- 비전시스템을위한딥러닝
- 혼공단
- 처음만나는WSL
- 웹최적화
- 한빛미디어
- 소문난명강의
- 처음 배우는 리액트 네이티브
- 오준석
- LEAN AI
- 셸스크립트
- 혼공파
- 마이크로서비스
- WSL2
- tensorflow_lite
- 처음시작하는_셸_스크립트
Archives
- Today
- Total
부산사는신씨
1. Spring + Thymeleaf 설정 하기 본문
전자정부 표준프레임워크에서 Thymeleaf 탬플릿 엔진을 사용해보고 싶었습니다.
환경
전자정부표준프레임워크 : 3.6
JDK : 1.8
Thymeleaf : 3.0
1. 설치(POM.xml)
org.thymeleaf thymeleaf 3.0.6.RELEASE org.slf4j slf4j-api org.thymeleaf thymeleaf-spring4 3.0.6.RELEASE org.slf4j slf4j-api
이유는 알 수 없으나 slf4j는 전자정부 프레임워크에 내장 된것보다 Thymeleaf에 내장된것이 버전이 더 낮습니다. 아래 그림과 같이요...
그로 인해 오류가 발생합니다.
저의 실수일수도 있으니 못믿겠다 하시는분은 해보셔도 됩니다.ㅋㅋㅋㅋ
2.설정(WEB-INF/config/egovframework/spingmvc/egov-thymeleaf.xml)
있어보이려고 xml 파일을 새로 생성 하여 설정 했습니다.
3.Sample
Controller(EgovMainController.java)
있는 자바 파일 그대로 사용 했습니다.
@Controller@SessionAttributes(types = ComDefaultVO.class) public class EgovMainController { ... @RequestMapping(value = "/cmm/main/mainPage.do") public String getMgtMainPage(HttpServletRequest request, ModelMap model) throws Exception{ // 공지사항 메인 컨텐츠 조회 시작 --------------------------------- BoardVO boardVO = new BoardVO(); boardVO.setPageUnit(5); boardVO.setPageSize(10); boardVO.setBbsId("BBSMSTR_AAAAAAAAAAAA"); PaginationInfo paginationInfo = new PaginationInfo(); paginationInfo.setCurrentPageNo(boardVO.getPageIndex()); paginationInfo.setRecordCountPerPage(boardVO.getPageUnit()); paginationInfo.setPageSize(boardVO.getPageSize()); boardVO.setFirstIndex(paginationInfo.getFirstRecordIndex()); boardVO.setLastIndex(paginationInfo.getLastRecordIndex()); boardVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage()); Mapmap = bbsMngService.selectBoardArticles(boardVO, "BBSA02"); model.addAttribute("notiList", map.get("resultList")); // 공지사항 메인컨텐츠 조회 끝 ----------------------------------- // 자유게시판 메인 컨텐츠 조회 시작 --------------------------------- boardVO.setPageUnit(9); boardVO.setPageSize(10); boardVO.setBbsId("BBSMSTR_BBBBBBBBBBBB"); paginationInfo.setCurrentPageNo(boardVO.getPageIndex()); paginationInfo.setRecordCountPerPage(boardVO.getPageUnit()); paginationInfo.setPageSize(boardVO.getPageSize()); boardVO.setFirstIndex(paginationInfo.getFirstRecordIndex()); boardVO.setLastIndex(paginationInfo.getLastRecordIndex()); boardVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage()); model.addAttribute("bbsList", bbsMngService.selectBoardArticles(boardVO, "BBSA02").get("resultList")); // 자유게시판 메인컨텐츠 조회 끝 ----------------------------------- // FAQ 메인 컨텐츠 조회 시작 --------------------------------- /** EgovPropertyService.SiteList */ FaqManageDefaultVO searchVO = new FaqManageDefaultVO(); searchVO.setPageUnit(3); searchVO.setPageSize(10); /** pageing */ paginationInfo.setCurrentPageNo(searchVO.getPageIndex()); paginationInfo.setRecordCountPerPage(searchVO.getPageUnit()); paginationInfo.setPageSize(searchVO.getPageSize()); searchVO.setFirstIndex(paginationInfo.getFirstRecordIndex()); searchVO.setLastIndex(paginationInfo.getLastRecordIndex()); searchVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage()); model.addAttribute("faqList", faqManageService.selectFaqList(searchVO)); // FAQ 메인 컨텐츠 조회 끝 ----------------------------------- // 설문참여 메인 컨텐츠 조회 시작 ----------------------------------- ComDefaultVO qVO = new ComDefaultVO(); qVO.setPageUnit(1); qVO.setPageSize(10); /** pageing */ paginationInfo.setCurrentPageNo(qVO.getPageIndex()); paginationInfo.setRecordCountPerPage(qVO.getPageUnit()); paginationInfo.setPageSize(qVO.getPageSize()); qVO.setFirstIndex(paginationInfo.getFirstRecordIndex()); qVO.setLastIndex(paginationInfo.getLastRecordIndex()); qVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage()); model.addAttribute("qriList", egovQustnrRespondInfoService.selectQustnrRespondInfoManageList(qVO)); // 설문참여 메인 컨텐츠 조회 끝 ----------------------------------- /** * * 위에 설정된대로 html 또는 xhtml로 끝나도록 return이 되어야 합니다. * * 위와 같이 설정 하면 return 값에 thymeleaf이 반드시 포함 되어야 합니다. * 그렇지 않으면 오류 화면을 보게 될것입니다.^^ */ return "main/EgovMainView.html"; } ... }
View(WEB-INF/templates/main/EgovMainView.html)
설정값과 동일 한 위치에 html 파일을 생성을 합니다.
prefix는 "/WEB-INF/templates/" suffix는 ".html"이므로 "WEB-INF/templates/main/EgovMainView.html" 이렇게 생성을 했습니다.
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <h1>Thymeleaf page!</h1> </body> </html>
이제 다 했습니다.
실행 이보시면 아래와 같이 나옵니다.
끝!^^
'Java > Spring+Thymeleaf' 카테고리의 다른 글
2. Thymeleaf + eclipse (0) | 2017.05.30 |
---|
Comments