本文整理汇总了Java中org.springframework.web.filter.HiddenHttpMethodFilter类的典型用法代码示例。如果您正苦于以下问题:Java HiddenHttpMethodFilter类的具体用法?Java HiddenHttpMethodFilter怎么用?Java HiddenHttpMethodFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HiddenHttpMethodFilter类属于org.springframework.web.filter包,在下文中一共展示了HiddenHttpMethodFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDispatcherContext
import org.springframework.web.filter.HiddenHttpMethodFilter; //导入依赖的package包/类
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, "/*");
}
示例2: getServletFilters
import org.springframework.web.filter.HiddenHttpMethodFilter; //导入依赖的package包/类
@Override
protected Filter[] getServletFilters(){
// создание фильтра кодировки, который позволит работать с русскими символами
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
characterEncodingFilter.setEncoding("UTF-8");
characterEncodingFilter.setForceEncoding(true);
// создание фильтра, который добавляет поддержку HTTP методов(например,таких как PUT)
HiddenHttpMethodFilter httpMethodFilter = new HiddenHttpMethodFilter();
return new Filter[]{characterEncodingFilter, httpMethodFilter};
}
示例3: onServletContextStartup
import org.springframework.web.filter.HiddenHttpMethodFilter; //导入依赖的package包/类
public void onServletContextStartup(ServletContext servletContext) throws ServletException {
//encodingFilter
registeredEncodingFilter(servletContext, CharacterEncodingFilter.class);
//hiddenHttpMethodFilter
registeredHiddenMethodFilter(servletContext, HiddenHttpMethodFilter.class);
//multipartFilter
registeredMultipartFilter(servletContext, SpringMultipartFilterProxy.class);
//systemFilter
registeredInitFilter(servletContext, BaseInitFilter.class);
//ajaxAnywhere
// registeredAjaxAnywhere(servletContext, AAFilter.class);
}
示例4: getServletFilters
import org.springframework.web.filter.HiddenHttpMethodFilter; //导入依赖的package包/类
@Override
protected Filter[] getServletFilters() {
CharacterEncodingFilter filter1 = new CharacterEncodingFilter();
filter1.setEncoding("utf-8");
filter1.setForceEncoding(true);
HttpPutFormContentFilter filter2 = new HttpPutFormContentFilter();
HiddenHttpMethodFilter filter3 = new HiddenHttpMethodFilter();
LOG.info("Adding filter to dispatcher servlet[CharacterEncodingFilter,HttpPutFormContentFilter,HiddenHttpMethodFilter]");
return new Filter[]{filter1, filter2, filter3};
}
示例5: getServletFilters
import org.springframework.web.filter.HiddenHttpMethodFilter; //导入依赖的package包/类
@Override
protected Filter[] getServletFilters() {
return new Filter[] {
new HiddenHttpMethodFilter(),
new DelegatingFilterProxy("a"),
new DelegatingFilterProxy("b"),
new DelegatingFilterProxy("c")
};
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:AnnotationConfigDispatcherServletInitializerTests.java
示例6: filterIsOrderedHighest
import org.springframework.web.filter.HiddenHttpMethodFilter; //导入依赖的package包/类
@Test
public void filterIsOrderedHighest() throws Exception {
load(OrderedConfiguration.class);
List<Filter> beans = new ArrayList<Filter>(
this.context.getBeansOfType(Filter.class).values());
AnnotationAwareOrderComparator.sort(beans);
assertThat(beans.get(0)).isInstanceOf(CharacterEncodingFilter.class);
assertThat(beans.get(1)).isInstanceOf(HiddenHttpMethodFilter.class);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:HttpEncodingAutoConfigurationTests.java
示例7: initHiddenHttpMethodFilter
import org.springframework.web.filter.HiddenHttpMethodFilter; //导入依赖的package包/类
/**
* <p>默认关闭<p>
* 加载HiddenHttpMethodFilter用于支持 HTTP PUT、DELETE(post模拟 put/delete)
* 在这处理过程中 HttpServletRequest对象需要修改 故此过滤器放置位置需要靠前(放在过滤字符之后)
* @param servletContext
* @see HiddenHttpMethodFilter
*/
protected void initHiddenHttpMethodFilter(ServletContext servletContext){
String enableHiddenHttpMethod = servletContext.getInitParameter("enableHiddenHttpMethod");
if(BooleanUtils.valueOf(enableHiddenHttpMethod)){
//HiddenHttpMethodFilter
HiddenHttpMethodFilter hiddenHttpMethodFilter = new HiddenHttpMethodFilter();
FilterRegistration filterRegistration = servletContext.addFilter("hiddenHttpMethodFilter", hiddenHttpMethodFilter);
filterRegistration.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/*");
}
}
示例8: filterIsOrderedHighest
import org.springframework.web.filter.HiddenHttpMethodFilter; //导入依赖的package包/类
@Test
public void filterIsOrderedHighest() throws Exception {
load(OrderedConfiguration.class);
List<Filter> beans = new ArrayList<Filter>(
this.context.getBeansOfType(Filter.class).values());
AnnotationAwareOrderComparator.sort(beans);
assertThat(beans.get(0), instanceOf(CharacterEncodingFilter.class));
assertThat(beans.get(1), instanceOf(HiddenHttpMethodFilter.class));
}
示例9: hiddenHttpMethodFilter
import org.springframework.web.filter.HiddenHttpMethodFilter; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(HiddenHttpMethodFilter.class)
public OrderedHiddenHttpMethodFilter hiddenHttpMethodFilter() {
OrderedHiddenHttpMethodFilter filter = new OrderedHiddenHttpMethodFilter();
filter.setMethodParam("_disable_spring_mvc_hidden_method_for_fucking_zuul");
return filter;
}
示例10: getServletFilters
import org.springframework.web.filter.HiddenHttpMethodFilter; //导入依赖的package包/类
@Override
protected Filter[] getServletFilters() {
CharacterEncodingFilter charFilter = new CharacterEncodingFilter();
charFilter.setEncoding("UTF-8");
charFilter.setForceEncoding(true);
return new Filter[] { new HiddenHttpMethodFilter(), charFilter, new HttpPutFormContentFilter() };
}
示例11: initializeWebApplication
import org.springframework.web.filter.HiddenHttpMethodFilter; //导入依赖的package包/类
/**
* Web Application.
*
* @param container
* {@code ServletContext}. Representation of the context that is serving
* the JEE application. Servlets, filters and listeners are registered
* via this interface.
*/
private void initializeWebApplication(ServletContext container)
{
AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext();
dispatcherContext.register(WebConfig.class);
DispatcherServlet webDispatcher = new DispatcherServlet(dispatcherContext);
ServletRegistration.Dynamic servletReg = container.addServlet(dispatcherWebName, webDispatcher);
servletReg.setLoadOnStartup(1);
servletReg.addMapping(URL_PATTERN_WEB);
HiddenHttpMethodFilter filter = new HiddenHttpMethodFilter();
FilterRegistration.Dynamic filterReg = container.addFilter("Hidden HTTP Method Filter", filter);
filterReg.addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST), true, dispatcherWebName);
}
示例12: createFilters
import org.springframework.web.filter.HiddenHttpMethodFilter; //导入依赖的package包/类
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);
}
示例13: getServletFilters
import org.springframework.web.filter.HiddenHttpMethodFilter; //导入依赖的package包/类
@Override
protected Filter[] getServletFilters() {
CharacterEncodingFilter charFilter = new CharacterEncodingFilter();
charFilter.setEncoding("UTF-8");
charFilter.setForceEncoding(true);
return new Filter[] { new HiddenHttpMethodFilter(), charFilter,
new HttpPutFormContentFilter() };
}
示例14: getServletFilters
import org.springframework.web.filter.HiddenHttpMethodFilter; //导入依赖的package包/类
@Override
protected Filter[] getServletFilters() {
HiddenHttpMethodFilter httpMethodFilter = new HiddenHttpMethodFilter();
CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
encodingFilter.setEncoding("UTF-8");
encodingFilter.setForceEncoding(true);
return new Filter[] { httpMethodFilter, encodingFilter };
}
示例15: onStartup
import org.springframework.web.filter.HiddenHttpMethodFilter; //导入依赖的package包/类
@Override
public void onStartup(final ServletContext container) throws ServletException {
// Create the root Spring application context
final AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(RootConfig.class);
// Manage the lifecycle of the root application context
final ContextLoaderListener contextLoaderListener = new ContextLoaderListener(rootContext);
container.addListener(contextLoaderListener);
// Create the dispatcher servlet's Spring application context
final AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext();
dispatcherContext.register(DispatcherConfig.class);
// Register and map the dispatcher servlet
final Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(dispatcherContext));
dispatcher.setLoadOnStartup(1);
// Make the dispatcher the default servlet (using "/" as per the Servlet 3.0 specification)
dispatcher.addMapping("/");
// Enables support for DELETE and PUT request methods with web browsers
container.addFilter("hiddenHttpMethodFilter", HiddenHttpMethodFilter.class).addMappingForUrlPatterns(null,
false,
"/*");
// Add Spring Security support
container.addFilter("springSecurityFilterChain", DelegatingFilterProxy.class).addMappingForUrlPatterns(null,
false,
"/*");
}