iamsungink / get-in-line-ex

코로나 줄서기 (예제)
0 stars 0 forks source link

jsp 프로그래밍 #8

Open iamsungink opened 3 weeks ago

iamsungink commented 3 weeks ago

jsp 프로그래밍 시 spring boot 설정 (with intellij)

iamsungink commented 3 weeks ago

WebApp 구성

  1. webapp 폴더생성
src/main/webapp

tomcat-jsper-dependency 추가하면 기본 설정을 탐 아래 참고

참고) JspTemplateAvailabilityProvider.java 참고

public class JspTemplateAvailabilityProvider implements TemplateAvailabilityProvider {

    @Override
    public boolean isTemplateAvailable(String view, Environment environment, ClassLoader classLoader,
            ResourceLoader resourceLoader) {
        if (ClassUtils.isPresent("org.apache.jasper.compiler.JspConfig", classLoader)) {
            String resourceName = getResourceName(view, environment);
            if (resourceLoader.getResource(resourceName).exists()) {
                return true;
            }
            try {
                return new File("src/main/webapp", resourceName).exists();
            }
            catch (AccessControlException ex) {
            }
        }
        return false;
    }

    private String getResourceName(String view, Environment environment) {
        String prefix = environment.getProperty("spring.mvc.view.prefix", WebMvcAutoConfiguration.DEFAULT_PREFIX);
        String suffix = environment.getProperty("spring.mvc.view.suffix", WebMvcAutoConfiguration.DEFAULT_SUFFIX);
        return prefix + view + suffix;
    }

}
  1. intellij에게 알려주기

Project Structure > Modules

main > Web

Web Resource Directories 추가

C:\data\projects\fastcampus\spring-full-edition\src\get-in-line-ex\src\main\webapp

OK 클릭

  1. jsp 바라보게되어있는 기본값을 바꿔주기

application.properties

spring.mvc.view.suffix=.html

인텔리제이에게는 webapp이 웹리소스 경로라는걸 알려줘야 되고

*** springboot은 jsp 프로그래밍을 한다면 일단 기본 값 src/main/webapp 기본경로로 봄

어려움

템필릿엔진을 사용해야 편함

starter-thymeleaf