search

Home  >  Q&A  >  body text

java - 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又正常能访问到.
是什么道理?或者有其他替代方案吗?

大家讲道理大家讲道理2898 days ago573

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-04-18 09:55:22

    If it is just a simple page jump, you can inherit the WebMvcConfigurerAdapter类,覆盖addViewControllers method and add ViewController for configuration.

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 09:55:22

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

    reply
    0
  • Cancelreply