我之前在2017年使用WebMvcConfigurerAdapter进行了安全层项目的登录和注册,但是现在不建议使用,因为我正在努力更新代码。
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
// Handles HTTP GET requests for /resources/** by efficiently serving up static
// resources in the ${webappRoot}/resources/ directory
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
}
//Resolves views selected for rendering by @Controllers to .jsp resources in the
// /WEB-INF/views directory
@Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setViewClass(JstlView.class);
viewResolver.setPrefix("/WEB-INF/views/");
viewResolver.setSuffix(".jsp");
viewResolver.setOrder(2);
return viewResolver;
}
@Bean
public SimpleMappingExceptionResolver simpleMappingExceptionResolver()
{
SimpleMappingExceptionResolver b = new SimpleMappingExceptionResolver();
Properties mappings = new Properties();
mappings.put("eMarket.controller.SpringException", "form/ExceptionPage");
mappings.put("defaultErrorView", "form/error");
b.setExceptionMappings(mappings);
return b;
}
}
我尝试使用
@Configuration
public class WebConfig implements WebMvcConfigurer { ... }
执行此操作时,会发生以下错误:
- The type WebConfig must implement the inherited abstract method
WebMvcConfigurer.configureContentNegotiation(ContentNegotiationConfigurer)
- The type WebConfig must implement the inherited abstract method WebMvcConfigurer.getValidator()
- The type WebConfig must implement the inherited abstract method
WebMvcConfigurer.extendMessageConverters(List<HttpMessageConverter<?>>)
- The type WebConfig must implement the inherited abstract method
WebMvcConfigurer.addCorsMappings(CorsRegistry)
- The type WebConfig must implement the inherited abstract method
WebMvcConfigurer.addArgumentResolvers(List<HandlerMethodArgumentResolver>)
- The type WebConfig must implement the inherited abstract method
WebMvcConfigurer.addInterceptors(InterceptorRegistry)
- The type WebConfig must implement the inherited abstract method
WebMvcConfigurer.getMessageCodesResolver()
- The type WebConfig must implement the inherited abstract method
WebMvcConfigurer.configureHandlerExceptionResolvers(List<HandlerExceptionResolver>)
- The type WebConfig must implement the inherited abstract method
WebMvcConfigurer.configureDefaultServletHandling(DefaultServletHandlerConfigurer)
- The type WebConfig must implement the inherited abstract method
WebMvcConfigurer.configurePathMatch(PathMatchConfigurer)
- The type WebConfig must implement the inherited abstract method
WebMvcConfigurer.addFormatters(FormatterRegistry)
- The type WebConfig must implement the inherited abstract method
WebMvcConfigurer.addReturnValueHandlers(List<HandlerMethodReturnValueHandler>)
- The type WebConfig must implement the inherited abstract method
WebMvcConfigurer.configureMessageConverters(List<HttpMessageConverter<?>>)
- The type WebConfig must implement the inherited abstract method
WebMvcConfigurer.configureViewResolvers(ViewResolverRegistry)
- The type WebConfig must implement the inherited abstract method
WebMvcConfigurer.configureAsyncSupport(AsyncSupportConfigurer)
- The type WebConfig must implement the inherited abstract method
WebMvcConfigurer.extendHandlerExceptionResolvers(List<HandlerExceptionResolver>)
- The type WebConfig must implement the inherited abstract method
WebMvcConfigurer.addViewControllers(ViewControllerRegistry)
关于为什么会被赞赏的想法