org.springframework.web.filter.HiddenHttpMethodFilter Java Examples

The following examples show how to use org.springframework.web.filter.HiddenHttpMethodFilter. 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: CommonWebFilterInitializer.java    From onetwo with Apache License 2.0 6 votes vote down vote up
public void onServletContextStartup(ServletContext servletContext) throws ServletException {
		//encodingFilter
		registeredEncodingFilter(servletContext, CharacterEncodingFilter.class);
		
//		multipartFilter
		registeredMultipartFilter(servletContext);
		
		//hiddenHttpMethodFilter 
		registeredHiddenMethodFilter(servletContext, HiddenHttpMethodFilter.class);
		
		//multipartFilter
//		registeredMultipartFilter(servletContext, SpringMultipartFilterProxy.class);

		//systemFilter
		registeredInitFilter(servletContext, BaseInitFilter.class);

		//ajaxAnywhere 
//		registeredAjaxAnywhere(servletContext, AAFilter.class);
		
	}
 
Example #2
Source File: SpringWebinitializer.java    From Spring-5.0-Cookbook with MIT License 6 votes vote down vote up
private void addDispatcherContext(ServletContext container) {
	// Create the dispatcher servlet's Spring application context
	AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext();
	dispatcherContext.register(SpringDispatcherConfig.class);

	// Declare <servlet> and <servlet-mapping> for the DispatcherServlet
	ServletRegistration.Dynamic dispatcher = container.addServlet("ch03-servlet",
			new DispatcherServlet(dispatcherContext));
	dispatcher.addMapping("*.html");
	dispatcher.setLoadOnStartup(1);

	FilterRegistration.Dynamic corsFilter = container.addFilter("corsFilter", new CorsFilter());
	corsFilter.setInitParameter("cors.allowed.methods", "GET, POST, HEAD, OPTIONS, PUT, DELETE");
	corsFilter.addMappingForUrlPatterns(null, true, "/*");

	FilterRegistration.Dynamic filter = container.addFilter("hiddenmethodfilter", new HiddenHttpMethodFilter());
	filter.addMappingForServletNames(null, true, "/*");

	FilterRegistration.Dynamic multipartFilter = container.addFilter("multipartFilter", new MultipartFilter());
	multipartFilter.addMappingForUrlPatterns(null, true, "/*");

}
 
Example #3
Source File: SpringWebInitializer.java    From Spring-5.0-Cookbook with MIT License 6 votes vote down vote up
private void addDispatcherContext(ServletContext container) {
	// Create the dispatcher servlet's Spring application context
	AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext();
	dispatcherContext.register(SpringDispatcherConfig.class);

	// Declare <servlet> and <servlet-mapping> for the DispatcherServlet
	ServletRegistration.Dynamic dispatcher = container.addServlet("ch03-servlet",
			new DispatcherServlet(dispatcherContext));
	dispatcher.addMapping("*.html");
	dispatcher.setLoadOnStartup(1);

	FilterRegistration.Dynamic corsFilter = container.addFilter("corsFilter", new CorsFilter());
	corsFilter.setInitParameter("cors.allowed.methods", "GET, POST, HEAD, OPTIONS, PUT, DELETE");
	corsFilter.addMappingForUrlPatterns(null, true, "/*");

	FilterRegistration.Dynamic filter = container.addFilter("hiddenmethodfilter", new HiddenHttpMethodFilter());
	filter.addMappingForServletNames(null, true, "/*");

	FilterRegistration.Dynamic multipartFilter = container.addFilter("multipartFilter", new MultipartFilter());
	multipartFilter.addMappingForUrlPatterns(null, true, "/*");

}
 
Example #4
Source File: WebApplicationInitializerImpl.java    From artemis with Apache License 2.0 5 votes vote down vote up
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    logger.info("===== Application is starting up! ========");

    try {
        XmlWebApplicationContext appContext = new XmlWebApplicationContext();
        appContext.setConfigLocation(APPLICATION_CONTEXT_FILE);

        ServletRegistration.Dynamic registration = servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(appContext));
        registration.setLoadOnStartup(1);
        registration.addMapping(DISPATCHER_SERVLET_MAPPING);

        // allow cross domain
        Filters.registerCrossDomainFilter(servletContext, DISPATCHER_SERVLET_MAPPING);

        // allow put/delete method
        servletContext.addFilter(HIDDEN_HTTP_METHOD_FILTER_NAME, new HiddenHttpMethodFilter());

        Filters.registerCompressingFilter(servletContext, DISPATCHER_SERVLET_MAPPING);

        DataConfig.init();

        DiscoveryServiceImpl.getInstance().addFilters(GroupDiscoveryFilter.getInstance(), ManagementDiscoveryFilter.getInstance());

        ManagementRepository.getInstance().addFilter(GroupDiscoveryFilter.getInstance());

        ClusterManager.INSTANCE.init(Lists.<NodeInitializer> newArrayList(ManagementInitializer.INSTANCE));
    } catch (Throwable ex) {
        logger.error("WebApplicationInitalizer failed.", ex);
        ex.printStackTrace();
        throw new ServletException(ex);
    }
}
 
Example #5
Source File: AppInitializer.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
	HiddenHttpMethodFilter httpMethodFilter = new HiddenHttpMethodFilter();

	CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
	encodingFilter.setEncoding("UTF-8");
	encodingFilter.setForceEncoding(true);

	return new Filter[] { httpMethodFilter, encodingFilter };
}
 
Example #6
Source File: AppInitializer.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
	HiddenHttpMethodFilter httpMethodFilter = new HiddenHttpMethodFilter();

	CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
	encodingFilter.setEncoding("UTF-8");
	encodingFilter.setForceEncoding(true);

	return new Filter[] { httpMethodFilter, encodingFilter };
}
 
Example #7
Source File: AppInitializer.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
	HiddenHttpMethodFilter httpMethodFilter = new HiddenHttpMethodFilter();

	CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
	encodingFilter.setEncoding("UTF-8");
	encodingFilter.setForceEncoding(true);

	return new Filter[] { httpMethodFilter, encodingFilter };
}
 
Example #8
Source File: AbstractWebApplicationInitializer.java    From bearchoke with Apache License 2.0 5 votes vote down vote up
protected void createFilters(ServletContext ctx) {
        CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
        characterEncodingFilter.setEncoding("UTF-8");

        SimpleCORSFilter corsFilter = new SimpleCORSFilter();
        corsFilter.setCorsAllowCredentials("true");
        corsFilter.setCorsAllowMethods("GET, POST, PUT, PATCH, DELETE, OPTIONS");
        corsFilter.setCorsAllowHeaders("content-type, x-requested-with, origin, accept, authorization, username, password, x-app-type, x-app-version, x-auth-token, soapaction");
        corsFilter.setCorsExposeHeaders("content-type, cookie, x-requested-with, origin, accept, username, password, x-app-type, x-app-version, x-auth-token, soapaction");
        corsFilter.setCorsMaxAge("3600");

        ctx.addFilter("springSessionRepositoryFilter", DelegatingFilterProxy.class).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
        ctx.addFilter("simpleCORSFilter", DelegatingFilterProxy.class).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
//        ctx.addFilter("SimpleCorsFilter", corsFilter).addMappingForUrlPatterns(
//                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
        ctx.addFilter("JsonHttpRequestFilter", new JsonHttpRequestFilter()).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, "/api/authenticate");
        ctx.addFilter("springSecurityFilterChain", DelegatingFilterProxy.class).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
        ctx.addFilter("CharacterEncodingFilter", characterEncodingFilter).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
        ctx.addFilter("HiddenHttpMethodFilter", new HiddenHttpMethodFilter()).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
        ctx.addFilter("HttpPutFormContentFilter", new HttpPutFormContentFilter()).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
        ctx.addFilter("ShallowEtagHeaderFilter", new ShallowEtagHeaderFilter()).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);

    }
 
Example #9
Source File: AnnotationConfigDispatcherServletInitializerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
	return new Filter[] {
			new HiddenHttpMethodFilter(),
			new DelegatingFilterProxy("a"),
			new DelegatingFilterProxy("b"),
			new DelegatingFilterProxy("c")
	};
}
 
Example #10
Source File: AnnotationConfigDispatcherServletInitializerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
	return new Filter[] {
			new HiddenHttpMethodFilter(),
			new DelegatingFilterProxy("a"),
			new DelegatingFilterProxy("b"),
			new DelegatingFilterProxy("c")
	};
}
 
Example #11
Source File: WebInitializer.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
    CharacterEncodingFilter cef = new CharacterEncodingFilter();
    cef.setEncoding("UTF-8");
    cef.setForceEncoding(true);
    return new Filter[]{new HiddenHttpMethodFilter(), cef};
}
 
Example #12
Source File: WebInitializer.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
    CharacterEncodingFilter cef = new CharacterEncodingFilter();
    cef.setEncoding("UTF-8");
    cef.setForceEncoding(true);
    return new Filter[]{new HiddenHttpMethodFilter(), cef};
}
 
Example #13
Source File: WebInitializer.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
    CharacterEncodingFilter cef = new CharacterEncodingFilter();
    cef.setEncoding("UTF-8");
    cef.setForceEncoding(true);
    return new Filter[]{new HiddenHttpMethodFilter(), cef};
}
 
Example #14
Source File: WebInitializer.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
    CharacterEncodingFilter cef = new CharacterEncodingFilter();
    cef.setEncoding("UTF-8");
    cef.setForceEncoding(true);
    return new Filter[]{new HiddenHttpMethodFilter(), cef};
}
 
Example #15
Source File: WebInitializer.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
    final CharacterEncodingFilter cef = new CharacterEncodingFilter();
    cef.setEncoding("UTF-8");
    cef.setForceEncoding(true);
    return new Filter[]{new HiddenHttpMethodFilter(), cef};
}
 
Example #16
Source File: WebInitializer.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
    CharacterEncodingFilter cef = new CharacterEncodingFilter();
    cef.setEncoding("UTF-8");
    cef.setForceEncoding(true);
    return new Filter[]{new HiddenHttpMethodFilter(), cef};
}
 
Example #17
Source File: AnnotationConfigDispatcherServletInitializerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
	return new Filter[] {
			new HiddenHttpMethodFilter(),
			new DelegatingFilterProxy("a"),
			new DelegatingFilterProxy("b"),
			new DelegatingFilterProxy("c")
	};
}
 
Example #18
Source File: SpeedupWebMvcAutoConfiguration.java    From spring-boot-web-support with GNU General Public License v3.0 4 votes vote down vote up
@Bean
@ConditionalOnProperty(value = NOOP_HIDDEN_HTTP_METHOD_FILTER_ENABLED_PROPERTY_NAME, havingValue = "true")
@ConditionalOnMissingBean(HiddenHttpMethodFilter.class)
public NoopOrderedHiddenHttpMethodFilter hiddenHttpMethodFilter() {
    return new NoopOrderedHiddenHttpMethodFilter();
}
 
Example #19
Source File: BaseApplicationConfig.java    From spring-boot-doma2-sample with Apache License 2.0 4 votes vote down vote up
@Bean
public HiddenHttpMethodFilter hiddenHttpMethodFilter() {
    // hiddenパラメータで指定されたHTTPメソッドに変換する
    return new HiddenHttpMethodFilter();
}
 
Example #20
Source File: J360AnnotaionWebApplicationInitializer.java    From j360-dubbo-app-all with Apache License 2.0 4 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
    return new Filter[] {
            new HiddenHttpMethodFilter(), new CharacterEncodingFilter() };
}
 
Example #21
Source File: RegistryAppInitializer.java    From konker-platform with Apache License 2.0 4 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
    return new Filter[]{new HiddenHttpMethodFilter(), new ResourceUrlEncodingFilter()};
}
 
Example #22
Source File: WallRideServletConfiguration.java    From wallride with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(HiddenHttpMethodFilter.class)
public OrderedHiddenHttpMethodFilter hiddenHttpMethodFilter() {
	return new OrderedHiddenHttpMethodFilter();
}
 
Example #23
Source File: HomeController.java    From odo with Apache License 2.0 4 votes vote down vote up
@Bean
public Filter hiddenHttpMethodFilter() {
    HiddenHttpMethodFilter filter = new HiddenHttpMethodFilter();
    return filter;
}
 
Example #24
Source File: WebMvcConfig.java    From enhanced-pet-clinic with Apache License 2.0 4 votes vote down vote up
@Bean
public FilterRegistrationBean hiddenFilterRegistrationBean() {
	return new FilterRegistrationBean(new HiddenHttpMethodFilter());
}