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 | 31 |
Tags
- 자바
- 백트래킹
- DP
- Java
- Til
- 항해99
- 그래프
- 동적 프로그래밍
- 99클럽
- 완전탐색
- BinarySearch
- SQL
- BFS
- 스프링 핵심 원리 - 기본편
- 개발qa
- 스프링
- 개발자취업
- 정렬
- 그래프 이론
- 개발q&a
- 알고리즘
- 코딩테스트준비
- 데이터베이스
- 백준
- 트리
- 학습기록
- DFS
- 그리디
- Spring
- 브루트포스
Archives
- Today
- Total
AtraFelis's Develop Diary
[Spring] ResponseBody Annotation 본문
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@Controller
public class basicController {
@RequestMapping("/")
public String hello() {
return "index.html";
}
}
웹페이지에 접속하면 index.html 문서를 불러와 띄워주는 간단한 함수이다.

당연히 index.html이라는 문서가 없는데 불러오려고 한다면,
![]()
이런 오류 페이지가 나타난다.
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@Controller
public class basicController {
@RequestMapping("/")
@ResponseBody
public String hello() {
return "index.html";
}
}
하지만 위와 같이 @ResponseBody를 붙인다면, index.html 문서가 반환되는 것이 아닌, "index.html"이라는 문자열이 그대로 반환된다.

'Programming > Spring' 카테고리의 다른 글
| [Spring] 스프링 컨테이너와 스프링 빈 (스프링 핵심원리 - 기본편 section5) (0) | 2025.01.12 |
|---|---|
| [Spring] 객체 지향 원리 적용하기 (스프링 핵심원리 - 기본편 section4) (2) | 2025.01.11 |
| [Spring] 객체 지향 설계와 스프링 (스프링 핵심 원리 - 기본편 Section2) (0) | 2025.01.10 |
| [Spring] 스프링 프레임워크와 스프링 부트 (1) | 2025.01.08 |
| [Spring] 김영한 님의 스프링 입문 강의를 수강하고 (1) | 2025.01.01 |