當前位置: 首頁>>代碼示例>>Java>>正文


Java DispatcherServlet.setThrowExceptionIfNoHandlerFound方法代碼示例

本文整理匯總了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);
}
 
開發者ID:esig,項目名稱:dss-demonstrations,代碼行數:25,代碼來源:AppInitializer.java

示例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;
}
 
開發者ID:Nike-Inc,項目名稱:backstopper,代碼行數:9,代碼來源:Main.java

示例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 中配置
}
 
開發者ID:ismartx,項目名稱:summer,代碼行數:29,代碼來源:SpringMvcWebAppInitializer.java

示例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;
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-web,代碼行數:7,代碼來源:MvcWebApplicationInitializer.java

示例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


注:本文中的org.springframework.web.servlet.DispatcherServlet.setThrowExceptionIfNoHandlerFound方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。