【发布时间】:2019-04-22 15:15:20
【问题描述】:
我的 Spring Boot 应用程序中有这段代码
@RestController
public class SampleController {
public SampleController() {
File file = new File("restresources");
System.out.println("File -> "+ file.getAbsolutePath());
}
@GetMapping(value = "/sample")
public String sampleText(HttpServletRequest request){
System.out.println("Sample Text");
return "Sample Text";
}
@RequestMapping()
public String acceptAny(){
return "ASDasdasdasdasd";
}
}
acceptAny 方法接受来自浏览器的任何 url?但我的公共文件夹中也有反应文件。因此,当我点击 localhost:8090/ 时,它没有加载 react index.html,而是加载了 acceptAny() 方法。
如何加载 react index.html 而不是调用这个 acceptAny() 方法,或者有什么方法可以从 Controller 本身加载 React index.html?
非常感谢任何帮助!
【问题讨论】:
-
什么时候应该调用
acceptAny()方法?换句话说,哪个 URL 将运行 acceptAny() 方法?
标签: spring reactjs spring-boot spring-mvc localhost