[英]Spring boot - Not rendering the landing(index.html) page?
我已经尝试了与 stackoverflow 中的问题相关的答案。 它没有成功。
这是我的项目结构:
Controller:渲染index.html
@Controller
public class MainController {
@RequestMapping(value="/",method = RequestMethod.GET)
public String homepage(){
System.out.println("Inside controller..");
return "index";
}
}
当我尝试点击URL
时,它会打印Inside controller..
但不会呈现index
页。 也尝试使用WebMvcConfigurerAdapter
。
在浏览器中,它显示一些错误,如Whitelabel Error Page
我在这里错过了什么吗?
检查浏览器控制台中的错误。 'X-Frame-Options' 可以设置为 'DENY',这可能会阻止 html 页面加载到浏览器中。
请检查您的项目结构。 应用程序和其他包如 model、controller 等应该在同一个 package 下或在同一级别。 还要确保在 application.yml/properties 文件中没有关于“spring.thymeleaf.prefix”的额外配置。
尝试使用带扩展名的全名,如 index.html
我认为你不应该返回字符串。 试试像ModelAndView
这样的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.