• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

안녕하세요 질문입니다.

21.06.22 17:28 작성 조회수 113

0

그대로 따라해도 /test1, /test2 가면 화이트라벨 에러 뜨는데 이유를 모르겠습니다. 

```

plugins {

id 'org.springframework.boot' version '2.5.1'

id 'io.spring.dependency-management' version '1.0.11.RELEASE'

id 'java'

id 'war'

}

group = 'com.study'

version = '0.0.1-SNAPSHOT'

sourceCompatibility = '1.8'

repositories {

mavenCentral()

}

dependencies {

implementation 'org.springframework.boot:spring-boot-starter-web'

providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'

testImplementation 'org.springframework.boot:spring-boot-starter-test'

    implementation 'javax.servlet:jstl'

    implementation 'org.apache.tomcat.embed:tomcat-embed-jasper'

}

test {

useJUnitPlatform()

}

```

-------

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Insert title here</title>

</head>

<body>

<%

    out.println("Hello World");

%>

</body>

</html>

--------

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Insert title here</title>

</head>

<body>

<%

    out.println("Hello World (sub)");

%>

</body>

</html>

----------

package com.study.springboot;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;

@Controller

public class MyController {

    @RequestMapping("/")

    public @ResponseBody String root() throws Exception{

        return "JSP in Gradle";

    }

 

    @RequestMapping("/test1")    // localhost:8081/test1

    public String test1() {

        return "test1";          // 실제 호출 될 /WEB-INF/views/test1.jsp       

    }

     

    @RequestMapping("/test2")    // localhost:8081/test2

    public String test2() {

        return "sub/test2";      // 실제 호출 될 /WEB-INF/views/sub/test2.jsp       

    }

}

-----------

server.port=8081

# JSP 설정

spring.mvc.view.prefix=/WEB-INF/views/

spring.mvc.view.suffix=.jsp

 

답변 2

·

답변을 작성해보세요.

0

Solioquies님의 프로필

Solioquies

질문자

2021.06.22

안에 제대로 넣은거 같은데도 잘 안되네요. (사진 처럼 폴더에 그대로 넣었습니다)임포트를 그대로 해봐도 잘 안되고 표시가 저렇게 java resource도 안나오는데 뭐가 문제일까요 ㅠ..

그리고 web.xml이 예제 소스에 없는데 계속 생기네요. 혹시 없어도 되는건가요? 에러부분 뜬다고 계속 떠서 여쭤봅니다.

0

jsp 를 보여 주기 위한 폴더 구성을 확인해 보세요. 그 부분이 틀린 것 같습니다.