美文网首页
springboot 简单变化直接定向到static静态页面

springboot 简单变化直接定向到static静态页面

作者: IT和金融 | 来源:发表于2018-04-18 00:00 被阅读0次

    在用springboot的时候,默认controller层访问到template下的动态页面,但有时候又想直接访问static下的静态页面
    默认是这样请求的

    @RequestMapping("/scene")
    
        public String scene() {
    
               return "pages/scene/scene_list";  //这里请求的路径默认是templates/pages/scene/scene_list.html页面
    
       }
    

    上面请求的是动态页面,那如果需要请求到static页面,用下面重定向方式就可以:

    
    @RequestMapping("/sb2")
    
        public String sb2() {
    
            return "redirect:sb-admin-2/index.html";  
    
        }
    

    此时请求的路径为:static/sb-admin-2/index.html页面,这样可以实现动态和静态页面的轻松选择

    相关文章

      网友评论

          本文标题:springboot 简单变化直接定向到static静态页面

          本文链接:https://www.haomeiwen.com/subject/piemkftx.html