Spring Boot无法找到控制器的映射

时间:2015-01-24 21:06:06

标签: java spring-mvc spring-boot

DataController

package go.controller;
@Controller
public class DataController {

    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String start(){
        return "index";
    }

WebMvcConfig

package go.config;
public class WebMvcConfig extends WebMvcConfigurerAdapter {
    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer){
        configurer.enable();
    }
    @Bean
    public InternalResourceViewResolver viewResolver(){
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setPrefix("WEB-INF/pages");
        viewResolver.setSuffix(".jsp");
        return viewResolver;
    }

}

StaticResourceConfiguration

package go.config;
public class StaticResourceConfiguration extends WebMvcConfigurerAdapter {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").addResourceLocations("/**");
    }
}

我在index.jsp

中有src/main/webapp/WEB-INF/pages/

为什么Spring Boot会显示404 Not found

0 个答案:

没有答案