Preloader image
DDD

자바

Spring Boot - JSP + thymeleaf 동시 사용 (application.properties)

작성자 관리자 (admin)
조회수 53
입력일 2023-05-12 11:38:38

-- 설정은 아래와 같이

** application.properties

# Thymeleaf

spring.thymeleaf.cache=false
spring.thymeleaf.prefix=classpath:templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.check-template-location=true
spring.thymeleaf.view-names=project/*

# JSTL - IBsheet Excel Down/Up
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp

-- Controller는 아래와같이

** test.java

package com.src.main.test;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class test {

    ///////////////////////////////////////////////
    // JSTL - JSP
    ///////////////////////////////////////////////
    @GetMapping("/jsp/name")
    public String jsp(Model model) {
        model.addAttribute("name", "홍길동");
        return "/main";
    }

    ///////////////////////////////////////////////
    // Thymleaf - HTML
    ///////////////////////////////////////////////
    @GetMapping("/admin/main")
    public String admin_main() {
        return "project/admin/main";
    }

    @GetMapping("/main")
    public String main() {
        return "project/main";
    }
    @GetMapping("/test")
    public String test() {
        return "project/test";
    }

}

-- 구조는 아래와 같이

├─java
│  └─com
│      └─src
│          └─main
│              ├─cmm
│              └─test <-- test.java
├─resources
│  ├─static
│  └─templates
│      └─project
│          └─admin
└─webapp
    └─WEB-INF
        └─jsp

 

^