• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    해결됨

질문있습니다!!!

22.04.19 16:59 작성 조회수 1.66k

1

public String hello(Model model) {
model.addAttribute("date","hello!!");
return "hello";
}
return 값이 templates의 hello.html에 지정이되지않습니다.

return 값이 templates패키지안의 hello.html 지정이 되지않습니다.

윈도우에서 Ctrl + 클릭해도 강사님처럼 html 파일로 따라가지지 않습니다. 
이유가 뭘까요?  다른부분있나 인강 몇번 돌려서 다시 작행했는데도 동일합니다.

http://localhost:8080/hello 들어가면 해당오류가 노출됩니다.

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Tue Apr 19 16:46:06 KST 2022
There was an unexpected error (type=Internal Server Error, status=500).

답변 1

답변을 작성해보세요.

0

David님의 프로필

David

2022.04.19

안녕하세요. 유영상님, 공식 서포터즈 David입니다.

1. 페이지 요청의 경우 아래와 같이 @GetMapping("hello")을 추가하셨나요? 그런데도 오류가 발생한다면 intellij 로그에 찍힌 에러를 글에 첨부해주세요.

2. return "템플릿명"을 눌렀을 때 이동하는 기능은 intellij 유료버전 기능입니다.


감사합니다.

 

유영상님의 프로필

유영상

질문자

2022.04.20

넵 @GetMapping 추가되어있습니다.

2022-04-20 10:56:20.276 ERROR 28996 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "'�ȳ��ϼ���. ' + $(date)" (template: "hello" - line 8, col 4)] with root cause

에러는 이렇게 나왔습니다.

 

근데 조금다른데 

@Controller

public class HelloController 요기에서 HelloController 이 회색입니다.

 

David님의 프로필

David

2022.04.20

$(date)라고 작성하셨네요. 소괄호'()'가 아니라 중괄호'{}'를 사용하셔야 합니다.

수정하시고 다시 해보시겠어요?

유영상님의 프로필

유영상

질문자

2022.04.20

악 ㅜㅜ 해결되었습니다. 감사합니다