Spring에서 default로 주어져있는 index.jsp를 사용할때 ` java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? ` 에러를 만날 수 있다.
이때는 index.jsp 파일을 view폴더에 넣고 다음과 같이 컨트롤러를 정의하여 해결할수 있다.
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
31
32
package com.gameTodoeyBackendClient.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import com.gameTodoeyBackendClient.admin.GameTodoeyAdmin;
@Controller
public class LoginController {
@GetMapping("/")
public String showHome() {
return "index";
}
@GetMapping("/showMyLoginPage")
public String showMyLoginPage() {
return "login";
}
// add request mapping for /access-denied
@GetMapping("/access-denied")
public String showAccessDenied() {
return "access-denied";
}
}