本文整理匯總了Java中org.springframework.web.servlet.DispatcherServlet.setThrowExceptionIfNoHandlerFound方法的典型用法代碼示例。如果您正苦於以下問題:Java DispatcherServlet.setThrowExceptionIfNoHandlerFound方法的具體用法?Java DispatcherServlet.setThrowExceptionIfNoHandlerFound怎麽用?Java DispatcherServlet.setThrowExceptionIfNoHandlerFound使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.web.servlet.DispatcherServlet
的用法示例。
在下文中一共展示了DispatcherServlet.setThrowExceptionIfNoHandlerFound方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onStartup
import org.springframework.web.servlet.DispatcherServlet; //導入方法依賴的package包/類
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
WebApplicationContext context = getContext();
servletContext.addListener(new ContextLoaderListener(context));
servletContext.addFilter("characterEncodingFilter", new CharacterEncodingFilter("UTF-8"));
DispatcherServlet dispatcherServlet = new DispatcherServlet(context);
dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("Dispatcher", dispatcherServlet);
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/*");
CXFServlet cxf = new CXFServlet();
BusFactory.setDefaultBus(cxf.getBus());
ServletRegistration.Dynamic cxfServlet = servletContext.addServlet("CXFServlet", cxf);
cxfServlet.setLoadOnStartup(1);
cxfServlet.addMapping("/services/*");
servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy("springSecurityFilterChain")).addMappingForUrlPatterns(null, false,
"/*");
servletContext.getSessionCookieConfig().setSecure(cookieSecure);
}
示例2: generateDispatcherServlet
import org.springframework.web.servlet.DispatcherServlet; //導入方法依賴的package包/類
private static DispatcherServlet generateDispatcherServlet(WebApplicationContext context) {
DispatcherServlet dispatcherServlet = new DispatcherServlet(context);
// By setting dispatcherServlet.setThrowExceptionIfNoHandlerFound() to true we get a NoHandlerFoundException thrown
// for a 404 instead of being forced to use error pages. The exception can be directly handled by Backstopper
// which is much preferred - you don't lose any context that way.
dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);
return dispatcherServlet;
}
示例3: onStartup
import org.springframework.web.servlet.DispatcherServlet; //導入方法依賴的package包/類
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.setInitParameter("contextConfigLocation", "classpath:spring-application.xml");
AnnotationConfigWebApplicationContext webContext = new AnnotationConfigWebApplicationContext();
webContext.register(WebConfig.class);
DispatcherServlet dispatcherServlet = new DispatcherServlet(webContext);
dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);
ServletRegistration.Dynamic registration = servletContext.addServlet("dispatcher", dispatcherServlet);
registration.setLoadOnStartup(1);
registration.addMapping("/");
servletContext.addListener(new ContextLoaderListener());
FilterRegistration.Dynamic characterEncodingFilter = servletContext.addFilter("CharacterEncodingFilter", CharacterEncodingFilter.class);
characterEncodingFilter.addMappingForUrlPatterns(null, false, "/*");
characterEncodingFilter.setInitParameter("encoding", "UTF-8");
characterEncodingFilter.setInitParameter("forceEncoding", "true");
FilterRegistration.Dynamic loggingFilter = servletContext.addFilter("loggingFilter", LoggingFilter.class);
loggingFilter.addMappingForUrlPatterns(null, false, "/*");
loggingFilter.setInitParameter("excludeUrl", "/files/*;/swagger*;/webjars/*;/favicon.ico");
FilterRegistration.Dynamic jwtTokenAuthFilter = servletContext.addFilter("jwtTokenAuthFilter", DelegatingFilterProxy.class);
jwtTokenAuthFilter.addMappingForUrlPatterns(null, false, "/api/*");
//excludeUrl 到 application.xml 中配置
}
示例4: createDispatcherServlet
import org.springframework.web.servlet.DispatcherServlet; //導入方法依賴的package包/類
@Override
protected FrameworkServlet createDispatcherServlet(final WebApplicationContext servletAppContext) {
final DispatcherServlet dispatcherServlet = new DispatcherServlet(servletAppContext);
dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);
return dispatcherServlet;
}
示例5: createDispatcherServlet
import org.springframework.web.servlet.DispatcherServlet; //導入方法依賴的package包/類
@Override
protected DispatcherServlet createDispatcherServlet(WebApplicationContext servletAppContext) {
final DispatcherServlet dispatcherServlet = super.createDispatcherServlet(servletAppContext);
dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);
return dispatcherServlet;
}
開發者ID:mattpwest,項目名稱:entelect-spring-webapp-template,代碼行數:7,代碼來源:SpringDispatcherServletInitializer.java