springBoot项目中的static和templates文件夹

记录是为了更好的成长!

1、static文件中的页面

//这样写不能访问static中index文件夹下的index.html页面    
@RequestMapping("index")
    public String hello() {
        return "/index/index";
    }
//这样写才能访问到
@RequestMapping("index")
    public String hello() {
        return "/index/index.html";
    }

 2、templates文件夹中的页面

3、springBoot项目中Controller层的页面重定向问题

    @RequestMapping("index")
    public String hello() {
        return "/index/index.html";
    }
    
   //请求test会重定向到index     
    @RequestMapping("test")
    public String test() {
        return "redirect:/index";
    }      

以上内容代表个人观点,仅供参考,不喜勿喷。。。

猜你喜欢

转载自www.cnblogs.com/newbest/p/9974959.html