0

当类扩展 AbstractAnnotationConfigDispatcherServletInitializer 时,我想知道类中以下方法的用途

  1. protected Class[] getRootConfigClasses() { return new Class[0]; }

    @覆盖

    1. protected Class[] getServletConfigClasses() { return new Class[] { testAPI.class }; } 3.@Override protected String[] getServletMappings() { return new String[] { "/" }; }
4

1 回答 1

0

(1) wants a list of @Configuration (user) classes for creating a Root ApplicationContext and (2) wants a list of (user) classes for the AnnotationConfigWebApplicationContext.

So image you have several @Configuration classes coded somewhere, you can register them with:

@Override
protected final Class<?>[] getRootConfigClasses() {
    return new Class[]{CoreConfiguration.class, JpaConfiguration.class,
            ShiroSecurityConfig.class};
} 
于 2015-03-01T01:02:43.700 回答