我有一个简单的 Spring Boot 应用程序。我正在尝试通过休息 Controller 加载 html 文件。下面是我的文件夹结构。我无法加载 test.html (就像其中的 helloworld 代码一样)
@RequestMapping("/show1")
public ModelAndView showpage1() {
System.out.println("## show1");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("test");
return modelAndView;
}
我的test.html内容
<h1> hello World </h1>
最佳答案
尝试这样做:
@RequestMapping("/show1")
public String showpage1() {
return "test";
}
其中 test.html 是您的页面
关于java - Spring-boot Rest api页面调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60273814/