There was an unexpected error (type=Not Found, status=404).
当我点击 http://localhost:8080 时在我的浏览器中呈现上述错误
MySpringBoot 起始页:
@SpringBootApplication
public class AppStart {
public static void main(String[] args) {
SpringApplication.run (AppStart.class,args);
}
}
我的 Controller :
@Controller
public class MyController {
@RequestMapping("/hello/{name}")
public @ResponseBody ModelAndView hello ( @PathVariable String name){
System.out.println("AppStartController:hello ");
ModelMap model = new ModelMap();
model.addAttribute("name", name);
return new ModelAndView("index");
}
}
我的 index.jsp 有“Hello World”文本。
最佳答案
通过在位于 src/main/resources/ 的 application.properties 中添加以下属性解决了这个问题,并且索引页面按预期显示。
spring.mvc.view.prefix:/
spring.mvc.view.suffix:.jsp
关于java - Spring Boot Web 应用程序 : JSP page throws 404 error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43540972/