spring boot项目只有src目录,没有webapp目录,会将静态访问(html/图片等)映射到其自动配置的静态目录,如下

/static

/public

/resources

/META-INF/resources

首先,在resources目录下先建立static文件夹,在建立/1/index.html文件

http://localhost/1/index.html 和 http://localhost/1/index.html都可以访问index.html页面

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Date 2018/8/29 0029
 */
@Controller
public class HtmlController {

    @RequestMapping("/1/index")
    public String text() {
        return "/1/index.html";
    }

}

 

相关文章:

  • 2022-12-23
  • 2021-10-29
  • 2021-05-28
  • 2021-11-28
  • 2021-05-23
  • 2021-12-06
  • 2021-10-07
猜你喜欢
  • 2021-11-08
  • 2022-12-23
  • 2021-11-20
  • 2022-02-06
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案