List of usage examples for org.springframework.web.servlet DispatcherServlet setDispatchOptionsRequest
public void setDispatchOptionsRequest(boolean dispatchOptionsRequest)
From source file:org.springsource.sinspctr.InspctrServer.java
@Override public void afterPropertiesSet() throws IOException { this.scheduler.setPoolSize(3); this.scheduler.initialize(); this.tomcat.setPort(this.port); Context tomcatContext = this.tomcat.addContext(this.contextPath, this.getClass().getClassLoader().getResources(".").nextElement().getFile()); this.webApplicationContext.setServletContext(tomcatContext.getServletContext()); this.webApplicationContext.refresh(); DispatcherServlet servlet = new DispatcherServlet(this.webApplicationContext); servlet.setDispatchOptionsRequest(true); Tomcat.addServlet(tomcatContext, this.servletName, servlet); tomcatContext.addServletMapping("/", this.servletName); if (logger.isInfoEnabled()) { logger.info("initialized server: context=" + this.contextPath + ", servlet=" + this.servletName); }//from ww w .j a v a 2 s. co m }
From source file:org.springframework.xd.dirt.server.AdminServer.java
/** * Create an embedded Tomcat instance and have it run the WebApplicationContext *//*ww w. j a va2s . com*/ @Override public void afterPropertiesSet() { this.scheduler.setPoolSize(3); this.scheduler.initialize(); this.tomcat.setPort(this.port); tomcatContext = this.tomcat.addContext(this.contextPath, new File(".").getAbsolutePath()); this.webApplicationContext.setServletContext(tomcatContext.getServletContext()); this.webApplicationContext.refresh(); // Options requests should be handled by StreamServer, not Tomcat // in order to handle CORS requests DispatcherServlet servlet = new DispatcherServlet(this.webApplicationContext); servlet.setDispatchOptionsRequest(true); Tomcat.addServlet(tomcatContext, this.servletName, servlet); tomcatContext.addServletMapping("/", this.servletName); FilterDef filterDef = new FilterDef(); filterDef.setFilterClass(HttpPutFormContentFilter.class.getName()); filterDef.setFilterName("httpPut"); FilterMap filterMap = new FilterMap(); filterMap.setFilterName("httpPut"); filterMap.addServletName(servletName); tomcatContext.addFilterDef(filterDef); tomcatContext.addFilterMap(filterMap); if (logger.isInfoEnabled()) { logger.info("initialized server: context=" + this.contextPath + ", servlet=" + this.servletName); } }