首页 > sprint boot 项目里"redirect:/index.html"到静态页面用eclipse运行错误.

sprint boot 项目里"redirect:/index.html"到静态页面用eclipse运行错误.

我不需要用到模板,所以把访问定向到static/index.html静态页面去.

@RequestMapping("/")

    public String index() {       
       
        return "redirect:/index.html";
    }

这么简单的语句在eclipse下把项目当程序运行提示404错误.
但gradle 构建的程序用命令行java -jar build/libs/xxx.jar又正常能访问到.
是什么道理?或者有其他替代方案吗?


报404明显工程部署问题喽~,搜下contextpath相关吧


如果只是简单的页面跳转,可以继承WebMvcConfigurerAdapter类,覆盖addViewControllers方法添加ViewController来进行配置。

【热门文章】
【热门文章】