mem*_*und 24 java spring spring-mvc spring-boot
我正在启动嵌入式tomcat via,spring-boot并希望将静态index.html页面作为正在运行的应用程序的一部分.
但以下不起作用:
@SpringBootApplication
public class HMyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}
@RestController
public class HomeContoller {
@RequestMapping("/")
public String index() {
return "index";
}
}
src/main/resources/static/index.html
Run Code Online (Sandbox Code Playgroud)
结果:当我打电话时localhost:8080,我只看到"索引"这个词,但不是我的html页面.为什么?
小智 9
对我来说这很有用,我相信有更好的方法(比如没有.html).
@RequestMapping("/")
public String index() {
return "index.html";
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
43114 次 |
| 最近记录: |