There was an unexpected error (type=Not Found, status=404).
时,我的浏览器中呈现了上述错误
MySpringBoot首页:
@SpringBootApplication
public class AppStart {
public static void main(String[] args) {
SpringApplication.run (AppStart.class,args);
}
}
我的控制器:
@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”文本。
答案 0 :(得分:1)
通过在 src / main / resources / 中的 application.properties 中添加以下属性,可以解决此问题,并按预期显示索引页。
spring.mvc.view.prefix:/
spring.mvc.view.suffix:.jsp