本文整理匯總了Java中org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter類的典型用法代碼示例。如果您正苦於以下問題:Java WebMvcConfigurerAdapter類的具體用法?Java WebMvcConfigurerAdapter怎麽用?Java WebMvcConfigurerAdapter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WebMvcConfigurerAdapter類屬於org.springframework.web.servlet.config.annotation包,在下文中一共展示了WebMvcConfigurerAdapter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: corsConfigurer
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; //導入依賴的package包/類
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
/* @Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/login*//*").allowedOrigins("*");
registry.addMapping("/recover*//*").allowedOrigins("*");
registry.addMapping("/tx*//*").allowedOrigins("*");
}
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new AuthInterceptor()).addPathPatterns("/**");
}
};
}
示例2: corsConfigurer
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; //導入依賴的package包/類
@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);
}
};
}
示例3: webMvcConfigurer
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; //導入依賴的package包/類
@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);
}
};
}
示例4: tracingHandlerInterceptor
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; //導入依賴的package包/類
@Bean
@ConditionalOnMissingBean(TracingFilter.class)
public WebMvcConfigurerAdapter tracingHandlerInterceptor(final Tracer tracer) {
log.info("Creating " + WebMvcConfigurerAdapter.class.getSimpleName() + " bean with " +
TracingHandlerInterceptor.class);
return new WebMvcConfigurerAdapter() {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new TracingHandlerInterceptor(tracer,
Arrays.asList(HandlerInterceptorSpanDecorator.STANDARD_LOGS,
HandlerInterceptorSpanDecorator.HANDLER_METHOD_OPERATION_NAME)));
super.addInterceptors(registry);
}
};
}
示例5: staticResourceConfigurer
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; //導入依賴的package包/類
@Bean
public WebMvcConfigurer staticResourceConfigurer() {
return new WebMvcConfigurerAdapter() {
@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/"
);
}
};
}
示例6: baseConfigurerBean
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; //導入依賴的package包/類
@Bean
public WebMvcConfigurerAdapter baseConfigurerBean(@Named final ScooldRequestInterceptor sri) {
return new WebMvcConfigurerAdapter() {
@Override
public void addInterceptors(InterceptorRegistry registry) {
super.addInterceptors(registry);
registry.addInterceptor(sri);
}
// @Override
// public void addResourceHandlers(ResourceHandlerRegistry registry) {
// registry.addResourceHandler("/images/**").addResourceLocations("/static/images/")
// .setCacheControl(CacheControl.maxAge(1, TimeUnit.HOURS).cachePublic());
// registry.addResourceHandler("/styles/**").addResourceLocations("/static/styles/")
// .setCacheControl(CacheControl.maxAge(1, TimeUnit.HOURS).cachePublic());
// registry.addResourceHandler("/scripts/**").addResourceLocations("/static/scripts/")
// .setCacheControl(CacheControl.maxAge(1, TimeUnit.HOURS).cachePublic());
// }
};
}
示例7: webMvcConfigurer
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; //導入依賴的package包/類
@Bean
public WebMvcConfigurer webMvcConfigurer(List<HandlerMethodArgumentResolver> handlerMethodArgumentResolvers) {
return new WebMvcConfigurerAdapter() {
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
super.addArgumentResolvers(argumentResolvers);
argumentResolvers.addAll(handlerMethodArgumentResolvers);
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new HandlerInterceptorAdapter() {
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
//clear thread local
ThreadLocalUtils.clear();
}
});
}
};
}
示例8: corsConfigurer
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; //導入依賴的package包/類
@Bean
WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/")
.allowedOrigins("*")
.allowedMethods("POST, GET, OPTIONS, DELETE ,PUT")
.allowedHeaders(AUTHORIZATION_HEADER, CONTENT_TYPE_HEADER, X_REQUESTED_WITH_HEADER, ACCEPT_HEADER, ORIGIN_HEADER,
AC_REQUEST_METHOD_HEADER, AC_REQUEST_HEADERS_HEADER, AC_ALLOW_ORIGIN_HEADER, AC_ALLOW_CREDENTIALS_HEADER, XXSRFTOKEN, XXSRFTOKEN2)
.exposedHeaders(AUTHORIZATION_HEADER, CONTENT_TYPE_HEADER, X_REQUESTED_WITH_HEADER, ACCEPT_HEADER, ORIGIN_HEADER,
AC_REQUEST_METHOD_HEADER, AC_REQUEST_HEADERS_HEADER, AC_ALLOW_ORIGIN_HEADER, XXSRFTOKEN, XXSRFTOKEN2)
.allowCredentials(true).maxAge(3600);
}
};
}
示例9: corsConfigurer
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; //導入依賴的package包/類
/**
* Spring4 Cors filter
* By default disabled
* @return
*/
@Bean
@ConditionalOnProperty(value="appverse.frontfacade.rest.cors.enabled", matchIfMissing=false)
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
public void addCorsMappings(CorsRegistry registry) {
String path = apiPath;
if (!StringUtils.isEmpty(corsPath)){
path = corsPath;
}
registry.addMapping(path + "/**")
.allowedOrigins(StringUtils.commaDelimitedListToStringArray(allowedOrigins))
.allowedMethods(StringUtils.commaDelimitedListToStringArray(allowedMethods))
.allowedHeaders(StringUtils.commaDelimitedListToStringArray(allowedHeaders))
.allowCredentials(Boolean.valueOf(allowedCredentials))
.maxAge(Long.valueOf(maxAge));
}
};
}
示例10: corsConfigurer
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; //導入依賴的package包/類
@Bean
public WebMvcConfigurer corsConfigurer()
{
return new WebMvcConfigurerAdapter() {
@Override
public void addCorsMappings(CorsRegistry registry)
{
registry.addMapping("/swagger/swagger-spec.yaml");
if (yonaProperties.getSecurity().isCorsAllowed())
{
// Enable CORS for the other resources, to allow testing the API through Swagger UI.
registry.addMapping("/**").allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE");
}
}
};
}
示例11: corsConfigurer
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; //導入依賴的package包/類
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
public void addCorsMappings(CorsRegistry registry) {
// Add CORS header for all path in application
registry.addMapping("/**") //
.allowedOrigins("*") //
.allowedMethods("POST", "GET", "OPTIONS", "DELETE", "PUT", "PATCH") //
.maxAge(3600) //
.allowedHeaders("x-requested-with", "Content-Type", "accept", "Authorization")
.exposedHeaders("Authorization")
.allowCredentials(true);
}
};
}
示例12: mvcViewConfigurer
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; //導入依賴的package包/類
@Bean
public WebMvcConfigurerAdapter mvcViewConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("search");
registry.addViewController("/monitor").setViewName("monitor");
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(new PageableHandlerMethodArgumentResolver());
}
};
}
示例13: corsConfigurer
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; //導入依賴的package包/類
@Bean
@SuppressWarnings("AnonymousInnerClassMayBeStatic")
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/v1/**")
.allowCredentials(true)
.allowedOrigins(Constants.UrlConstants.ALLOWED_ORIGINS)
.allowedMethods("GET", "HEAD", "POST", "PATCH", "DELETE", "OPTIONS");
}
};
}
示例14: corsConfigurer
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; //導入依賴的package包/類
/**
* Activation de CORS pour tous les domaines.
*
* @return Configurateur Spring MVC.
*/
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins("*");
}
};
}
示例15: forwardToIndex
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; //導入依賴的package包/類
@Bean
public WebMvcConfigurerAdapter forwardToIndex() {
return new WebMvcConfigurerAdapter() {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
// forward requests to /admin and /user to their index.html
registry.addViewController("/**").setViewName(
"forward:/index.html");
}
};
}