2017-04-21 132 views
0
There was an unexpected error (type=Not Found, status=404). 

在瀏覽器中呈現,同時創下了http://localhost:8080SpringBoot Web應用程序:JSP頁面拋出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」文本。

回答

1

通過application.properties它位於的src/main /資源將以下屬性/解決了這個問題,並如預期的那樣顯示的索引頁。

spring.mvc.view.prefix:/ 
spring.mvc.view.suffix:.jsp