Java Code Examples for org.springframework.web.servlet.DispatcherServlet#setContextClass()
The following examples show how to use
org.springframework.web.servlet.DispatcherServlet#setContextClass() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebIntegrationIT.java From tracee with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Before public void startJetty() throws Exception { Tracee.getBackend().clear(); server = new Server(new InetSocketAddress("127.0.0.1", 0)); ServletContextHandler context = new ServletContextHandler(null, "/", ServletContextHandler.NO_SECURITY); final DispatcherServlet dispatcherServlet = new DispatcherServlet(); dispatcherServlet.setContextClass(AnnotationConfigWebApplicationContext.class); dispatcherServlet.setContextInitializerClasses(TraceeInterceptorSpringApplicationInitializer.class.getCanonicalName()); dispatcherServlet.setContextConfigLocation(TraceeInterceptorSpringConfig.class.getName()); context.addServlet(new ServletHolder(dispatcherServlet), "/"); server.setHandler(context); server.start(); ENDPOINT_URL = "http://" + server.getConnectors()[0].getName() + "/"; }
Example 2
Source File: ContextLoaderTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testFrameworkServletWithDefaultLocation() throws Exception { DispatcherServlet servlet = new DispatcherServlet(); servlet.setContextClass(XmlWebApplicationContext.class); try { servlet.init(new MockServletConfig(new MockServletContext(""), "test")); fail("Should have thrown BeanDefinitionStoreException"); } catch (BeanDefinitionStoreException ex) { // expected assertTrue(ex.getCause() instanceof IOException); assertTrue(ex.getCause().getMessage().contains("/WEB-INF/test-servlet.xml")); } }
Example 3
Source File: ContextLoaderTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testFrameworkServletWithDefaultLocation() throws Exception { DispatcherServlet servlet = new DispatcherServlet(); servlet.setContextClass(XmlWebApplicationContext.class); try { servlet.init(new MockServletConfig(new MockServletContext(""), "test")); fail("Should have thrown BeanDefinitionStoreException"); } catch (BeanDefinitionStoreException ex) { // expected assertTrue(ex.getCause() instanceof IOException); assertTrue(ex.getCause().getMessage().contains("/WEB-INF/test-servlet.xml")); } }
Example 4
Source File: ActivitiUIApplication.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Bean public ServletRegistrationBean apiDispatcher() { DispatcherServlet api = new DispatcherServlet(); api.setContextClass(AnnotationConfigWebApplicationContext.class); api.setContextConfigLocation(ApiDispatcherServletConfiguration.class.getName()); ServletRegistrationBean registrationBean = new ServletRegistrationBean(); registrationBean.setServlet(api); registrationBean.addUrlMappings("/api/*"); // api下面的所有内容都访问到这里 registrationBean.setLoadOnStartup(1); registrationBean.setAsyncSupported(true); registrationBean.setName("api"); // 不能重复,重复则以最后一个设置的为准 return registrationBean; }
Example 5
Source File: ActivitiUIApplication.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Bean public ServletRegistrationBean appDispatcher() { DispatcherServlet api = new DispatcherServlet(); api.setContextClass(AnnotationConfigWebApplicationContext.class); api.setContextConfigLocation(AppDispatcherServletConfiguration.class.getName()); ServletRegistrationBean registrationBean = new ServletRegistrationBean(); registrationBean.setServlet(api); registrationBean.addUrlMappings("/app/*"); // app下面的所有内容都访问到这里 registrationBean.setLoadOnStartup(1); registrationBean.setAsyncSupported(true); registrationBean.setName("app"); // 不能重复,重复则以最后一个设置的为准 return registrationBean; }
Example 6
Source File: ContextLoaderTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testFrameworkServletWithDefaultLocation() throws Exception { DispatcherServlet servlet = new DispatcherServlet(); servlet.setContextClass(XmlWebApplicationContext.class); try { servlet.init(new MockServletConfig(new MockServletContext(""), "test")); fail("Should have thrown BeanDefinitionStoreException"); } catch (BeanDefinitionStoreException ex) { // expected assertTrue(ex.getCause() instanceof IOException); assertTrue(ex.getCause().getMessage().contains("/WEB-INF/test-servlet.xml")); } }
Example 7
Source File: WebApplicationConfiguration.java From junit-servers with MIT License | 5 votes |
private void initSpringMvc(ServletContext servletContext, AnnotationConfigWebApplicationContext context) { DispatcherServlet dispatcherServlet = new DispatcherServlet(context); dispatcherServlet.setContextConfigLocation(configLocation()); dispatcherServlet.setContextClass(AnnotationConfigWebApplicationContext.class); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("spring", dispatcherServlet); dispatcher.setLoadOnStartup(1); dispatcher.addMapping("/*"); dispatcher.addMapping("/"); }
Example 8
Source File: WebApplicationConfiguration.java From junit-servers with MIT License | 5 votes |
private void initSpringMvc(ServletContext servletContext, AnnotationConfigWebApplicationContext context) { DispatcherServlet dispatcherServlet = new DispatcherServlet(context); dispatcherServlet.setContextConfigLocation(configLocation()); dispatcherServlet.setContextClass(AnnotationConfigWebApplicationContext.class); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("spring", dispatcherServlet); dispatcher.setLoadOnStartup(1); dispatcher.addMapping("/*"); dispatcher.addMapping("/"); }
Example 9
Source File: WebApplicationConfiguration.java From junit-servers with MIT License | 5 votes |
private void initSpringMvc(ServletContext servletContext, AnnotationConfigWebApplicationContext context) { DispatcherServlet dispatcherServlet = new DispatcherServlet(context); dispatcherServlet.setContextConfigLocation(configLocation()); dispatcherServlet.setContextClass(AnnotationConfigWebApplicationContext.class); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("spring", dispatcherServlet); dispatcher.setLoadOnStartup(1); dispatcher.addMapping("/*"); dispatcher.addMapping("/"); }
Example 10
Source File: WebApplicationConfiguration.java From junit-servers with MIT License | 5 votes |
private void initSpringMvc(ServletContext servletContext, AnnotationConfigWebApplicationContext context) { DispatcherServlet dispatcherServlet = new DispatcherServlet(context); dispatcherServlet.setContextConfigLocation(configLocation()); dispatcherServlet.setContextClass(AnnotationConfigWebApplicationContext.class); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("spring", dispatcherServlet); dispatcher.setLoadOnStartup(1); dispatcher.addMapping("/*"); dispatcher.addMapping("/"); }