天天看点

spring boot 修改DispatcherServlet默认拦截路径

转载自:http://blog.csdn.net/catoop/article/details/50501686,进个人学习记录之用,原文还记录了servlet的用法。

我们在SpringBootSampleApplication中添加代码:

/**
     * 修改DispatcherServlet默认配置
     *
     * @param dispatcherServlet
     * @return
     * @author SHANHY
     * @create  2016年1月6日
     */
    @Bean
    public ServletRegistrationBean dispatcherRegistration(DispatcherServlet dispatcherServlet) {
        ServletRegistrationBean registration = new ServletRegistrationBean(dispatcherServlet);
        registration.getUrlMappings().clear();
        registration.addUrlMappings("*.do");
        registration.addUrlMappings("*.json");
        return registration;
    }
           

继续阅读