java - sprint boot 项目里"redirect:/index.html"到静态页面用eclipse运行错误.
大家讲道理
大家讲道理 2017-04-18 09:53:22
0
2
478

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

@RequestMapping("/")

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

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

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all (2)
巴扎黑

If it is just a simple page jump, you can inherit theWebMvcConfigurerAdapter类,覆盖addViewControllersmethod and add ViewController for configuration.

    刘奇

    Reporting 404 is an obvious project deployment problem~, search for contextpath related information

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!