我的请求可以进入我的Welcomecontroller的方法,但似乎该方法无法返回freemarker页面给我或者spring boot没有区分freemarker(我已将.ftl文件放入/resources/templates/)
当我输入网址http://localhost:8080/index时
我从 chrome 中得到了这个,并且在 IDEA 的控制台中没有报告任何错误:
Whitelabel 错误页面 此应用程序没有 /error 的显式映射,因此您将其视为后备。
2020 年 1 月 4 日星期六 22:52:53 CST 出现意外错误(类型=未找到,状态=404)。没有可用的消息
我的代码如下:
@Controller
public class WelcomeController {
@Value("${application.message}")
private String message;
@GetMapping("/index")
public String welcome(Map<String, Object> model) {
model.put("time", new Date());
model.put("message", this.message);
return "welcome";
}
}
Run Code Online (Sandbox Code Playgroud)
@SpringBootApplication
public class QuestionsiteApplication {
public static void main(String[] args) {
SpringApplication.run(QuestionsiteApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
欢迎.ftl:
<!DOCTYPE html>
<html lang="en">
<body>
Date: ${time?date}
<br>
Time: ${time?time}
<br>
Message: ${message}
</body>
</html> …
Run Code Online (Sandbox Code Playgroud)