org.springframework.web.servlet.config.annotation.WebMvcConfigurer Java Examples
The following examples show how to use
org.springframework.web.servlet.config.annotation.WebMvcConfigurer.
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: Application.java From syndesis with Apache License 2.0 | 6 votes |
@Bean public WebMvcConfigurer staticResourceConfigurer() { return new WebMvcConfigurer() { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry .addResourceHandler("/mapper/**") .addResourceLocations( "classpath:/META-INF/syndesis/mapper/", "classpath:/META-INF/resources/mapper/", "classpath:/static/mapper/", "classpath:/resources/mapper/" ); } }; }
Example #2
Source File: AdminApplication.java From mogu_blog_v2 with Apache License 2.0 | 6 votes |
/** * 跨域过滤器 * * @return */ // @Bean // public CorsFilter corsFilter() { // UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); // source.registerCorsConfiguration("/**", buildConfig()); // return new CorsFilter(source); // } @Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurer() { @Override public void addCorsMappings(CorsRegistry registry) { //配置允许跨域访问的路径 registry.addMapping("/**/**") .allowedOrigins("*") .allowedMethods("*") .allowedHeaders("*") .allowCredentials(true) .exposedHeaders("") .maxAge(3600); } }; }
Example #3
Source File: ServerTracingAutoConfiguration.java From java-spring-web with Apache License 2.0 | 6 votes |
@Bean @ConditionalOnMissingBean(TracingFilter.class) public WebMvcConfigurer tracingHandlerInterceptor(final Tracer tracer) { log.info("Creating " + WebMvcConfigurer.class.getSimpleName() + " bean with " + TracingHandlerInterceptor.class); return new WebMvcConfigurer() { @Override public void addInterceptors(InterceptorRegistry registry) { List<HandlerInterceptorSpanDecorator> decorators = interceptorSpanDecorator.getIfAvailable(); if (CollectionUtils.isEmpty(decorators)) { decorators = Arrays.asList(HandlerInterceptorSpanDecorator.STANDARD_LOGS, HandlerInterceptorSpanDecorator.HANDLER_METHOD_OPERATION_NAME); } registry.addInterceptor(new TracingHandlerInterceptor(tracer, decorators)); } }; }
Example #4
Source File: Application.java From basic with MIT License | 6 votes |
@Bean public WebMvcConfigurer webMvcConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addViewControllers(ViewControllerRegistry viewControllerRegistry) { // 首页默认加载web端 viewControllerRegistry.addViewController("/").setViewName("/web/index.html"); viewControllerRegistry.addViewController("/index.html").setViewName("redirect:/"); // web首页 viewControllerRegistry.addViewController("/web").setViewName("/web/index.html"); // webapp首页 viewControllerRegistry.addViewController("/webapp").setViewName("/webapp/index.html"); viewControllerRegistry.setOrder(Ordered.HIGHEST_PRECEDENCE); super.addViewControllers(viewControllerRegistry); } }; }
Example #5
Source File: DemoApplication.java From n2o-framework with Apache License 2.0 | 6 votes |
@Bean public WebMvcConfigurer forwardToIndex() { return new WebMvcConfigurer() { @Override public void addViewControllers(ViewControllerRegistry registry) { // forward requests to /admin and /user to their index.html registry.addViewController("/docs/manual/").setViewName( "forward:/docs/manual/index.html"); registry.addViewController("/docs/xml/").setViewName( "forward:/docs/xml/index.html"); registry.addViewController("/docs/storybook/").setViewName( "forward:/docs/storybook/index.html"); registry.addViewController("/docs/esdoc/").setViewName( "forward:/docs/esdoc/index.html"); } // @Override // public void addResourceHandlers(ResourceHandlerRegistry registry) { // registry.addResourceHandler("/{x:^(?!docs$).*$}/**") // .addResourceLocations("classpath:/META-INF/resources/") // .resourceChain(true) // .addResolver(new SPAResolver()); // } }; }
Example #6
Source File: ConfigurableContentNegotiationManagerWebMvcConfigurerTest.java From spring-webmvc-support with GNU General Public License v3.0 | 6 votes |
@Test public void testConfigureContentNegotiationOnDefaultValues() { WebMvcConfigurer webMvcConfigurer = new ConfigurableContentNegotiationManagerWebMvcConfigurer(new HashMap<String, String>()); ContentNegotiationConfigurer configurer = new ContentNegotiationConfigurer(new MockServletContext()); webMvcConfigurer.configureContentNegotiation(configurer); ContentNegotiationManagerFactoryBean factoryBean = FieldUtils.getFieldValue(configurer, "factory", ContentNegotiationManagerFactoryBean.class); Assert.assertTrue(FieldUtils.getFieldValue(factoryBean, "favorPathExtension", boolean.class)); Assert.assertFalse(FieldUtils.getFieldValue(factoryBean, "favorParameter", boolean.class)); Assert.assertFalse(FieldUtils.getFieldValue(factoryBean, "ignoreAcceptHeader", boolean.class)); Assert.assertNull(FieldUtils.getFieldValue(factoryBean, "useJaf", Boolean.class)); Assert.assertEquals("format", FieldUtils.getFieldValue(factoryBean, "parameterName", String.class)); Assert.assertTrue(FieldUtils.getFieldValue(factoryBean, "mediaTypes", Map.class).isEmpty()); Assert.assertNull(FieldUtils.getFieldValue(factoryBean, "defaultContentType", MediaType.class)); }
Example #7
Source File: WebMvcConfig.java From mayday with GNU General Public License v3.0 | 5 votes |
/** * 释放静态资源 */ @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/"); // 通过addResourceHandler添加资源映射路径,然后通过addResourceLocations来指定路径。可以访问自定义upload文件夹 registry.addResourceHandler("/upload/**").addResourceLocations("classpath:/upload/") .addResourceLocations("file:///" + System.getProperties().getProperty("user.home") + "/mayday/upload/"); registry.addResourceHandler("/source/**").addResourceLocations("classpath:/templates/themes/"); WebMvcConfigurer.super.addResourceHandlers(registry); }
Example #8
Source File: SecurityConfiguration.java From Spring-Boot-2-Fundamentals with MIT License | 5 votes |
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurer() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/greeting-javaconfig").allowedOrigins("http://localhost:9000"); } }; }
Example #9
Source File: SecurityConfiguration.java From Spring-Boot-2-Fundamentals with MIT License | 5 votes |
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurer() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/greeting-javaconfig").allowedOrigins("http://localhost:9000"); } }; }
Example #10
Source File: DvAutoConfiguration.java From syndesis with Apache License 2.0 | 5 votes |
@Bean protected WebMvcConfigurer webMvcConfigurer() { return new WebMvcConfigurer() { @Override @SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE") // false positive public void configureAsyncSupport(AsyncSupportConfigurer configurer) { configurer.setTaskExecutor(getAsyncExecutor()); } }; }
Example #11
Source File: HmilyAdminConfiguration.java From hmily with Apache License 2.0 | 5 votes |
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurer() { @Override public void addInterceptors(final InterceptorRegistry registry) { registry.addInterceptor(new AuthInterceptor()).addPathPatterns("/**"); } }; }
Example #12
Source File: CORSConfiguration.java From paraflow with Apache License 2.0 | 5 votes |
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedHeaders("*") .allowedMethods("*") .allowedOrigins("*"); } }; }
Example #13
Source File: WebSecurityConfig.java From digag-server with Apache License 2.0 | 5 votes |
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**").allowedOrigins("*") .allowedMethods("GET", "HEAD", "POST","PUT", "DELETE", "OPTIONS") .allowCredentials(false).maxAge(3600); } }; }
Example #14
Source File: AdminConfiguration.java From Raincat with GNU Lesser General Public License v3.0 | 5 votes |
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurer() { @Override public void addInterceptors(final InterceptorRegistry registry) { registry.addInterceptor(new AuthInterceptor()).addPathPatterns("/**"); } }; }
Example #15
Source File: Application.java From spring-boot-react-maven-starter with Apache License 2.0 | 5 votes |
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**").allowedMethods("*").allowedOrigins("http://localhost:3000"); } }; }
Example #16
Source File: CORSConfig.java From LazyREST with Apache License 2.0 | 5 votes |
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins(ALL) .allowedMethods(ALL) .allowedHeaders(ALL) .allowCredentials(true); } }; }
Example #17
Source File: I18nApplication.java From Spring-Boot-I18n-Pro with MIT License | 5 votes |
@Bean public WebMvcConfigurer webMvcConfigurer() { return new WebMvcConfigurer() { //拦截器 @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new LocaleChangeInterceptor()).addPathPatterns("/**"); registry.addInterceptor(new MessageResourceInterceptor()).addPathPatterns("/**"); } }; }
Example #18
Source File: OpenAPI2SpringBoot.java From openapi-generator with Apache License 2.0 | 5 votes |
@Bean public WebMvcConfigurer webConfigurer() { return new WebMvcConfigurerAdapter() { /*@Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("*") .allowedMethods("*") .allowedHeaders("Content-Type"); }*/ }; }
Example #19
Source File: CouponApplication.java From kakaopay-coupon with MIT License | 5 votes |
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/api/v1/*").allowedOrigins("http://localhost:8081"); } }; }
Example #20
Source File: CorsConfig.java From balance-transfer-java with Apache License 2.0 | 5 votes |
@Bean public WebMvcConfigurer mvcConfigurer() { return new WebMvcConfigurerAdapter() { public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**").allowedMethods("GET", "PUT", "POST", "GET", "OPTIONS"); } }; }
Example #21
Source File: BeanFactory.java From microservices-basics-spring-boot with Apache License 2.0 | 5 votes |
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**").allowedMethods("HEAD", "GET", "POST", "PUT", "DELETE", "PATCH") .allowedHeaders("*"); } }; }
Example #22
Source File: ServerAutoConfiguration.java From sofa-lookout with Apache License 2.0 | 5 votes |
/** * for webmvc * * @return */ @Bean public WebMvcConfigurer forwardToIndex() { return new WebMvcConfigurer() { @Override public void addViewControllers(ViewControllerRegistry registry) { // forward requests to /admin and /user to their index.html registry.addViewController("/").setViewName("redirect:/index.html"); } }; }
Example #23
Source File: WebConfigCORS.java From pacbot with Apache License 2.0 | 5 votes |
/** * Cors configurer. * * @return the web mvc configurer */ @Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { if ("all".equals(allowedOrigions)) { registry.addMapping("/**"); } else { registry.addMapping("/**").allowedOrigins(allowedOrigions); } } }; }
Example #24
Source File: WebConfigCORS.java From pacbot with Apache License 2.0 | 5 votes |
/** * Cors configurer. * * @return the web mvc configurer */ @Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { if ("all".equals(allowedOrigions)) { registry.addMapping("/**"); } else { registry.addMapping("/**").allowedOrigins(allowedOrigions); } } }; }
Example #25
Source File: AdminConfiguration.java From myth with Apache License 2.0 | 5 votes |
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurer() { @Override public void addInterceptors(final InterceptorRegistry registry) { registry.addInterceptor(new AuthInterceptor()).addPathPatterns("/**"); } }; }
Example #26
Source File: LdapSecurityConfiguration.java From data-highway with Apache License 2.0 | 5 votes |
@Bean public WebMvcConfigurer webConfig() { return new WebMvcConfigurer() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**").allowedMethods("HEAD", "GET", "PUT", "POST", "DELETE", "PATCH"); } }; }
Example #27
Source File: TxManagerConfiguration.java From Lottor with MIT License | 5 votes |
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedHeaders("*") .allowedMethods("*") .allowedOrigins("*"); } }; }
Example #28
Source File: OpenAPI2SpringBoot.java From swaggy-jenkins with MIT License | 5 votes |
@Bean public WebMvcConfigurer webConfigurer() { return new WebMvcConfigurer() { /*@Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("*") .allowedMethods("*") .allowedHeaders("Content-Type"); }*/ }; }
Example #29
Source File: OpenAPI2SpringBoot.java From openapi-generator with Apache License 2.0 | 5 votes |
@Bean public WebMvcConfigurer webConfigurer() { return new WebMvcConfigurer() { /*@Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("*") .allowedMethods("*") .allowedHeaders("Content-Type"); }*/ }; }
Example #30
Source File: OpenAPI2SpringBoot.java From openapi-generator with Apache License 2.0 | 5 votes |
@Bean public WebMvcConfigurer webConfigurer() { return new WebMvcConfigurer() { /*@Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("*") .allowedMethods("*") .allowedHeaders("Content-Type"); }*/ }; }