에서 javax.servlet 버전 javax.servlet.FilterRegistration을 가져 어차피 나는이 수입에 문제가 있어요 :나는 스프링 MVC 웹 응용 프로그램에서 일하고 있어요 2.5
는import javax.servlet.FilterRegistration;
import javax.servlet.ServletRegistration;
오류가 The import javax.servlet.FilterRegistration cannot be resolved
이 내가 오류 의존성이 받는다는 더 이상
이 표시되지 않습니다 넣으면public class InitApp implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext container)
{
// Create the 'root' Spring application context
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(RootConfig.class);
// Manage the lifecycle of the root application context
container.addListener(new ContextLoaderListener(rootContext));
// Create the dispatcher servlet's Spring application context
AnnotationConfigWebApplicationContext dispatcherServlet = new AnnotationConfigWebApplicationContext();
dispatcherServlet.register(MvcConfig.class);
// Register and map the dispatcher servlet
ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(dispatcherServlet));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
}
private void registerCharacterEncodingFilter(ServletContext servletContext) {
CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
encodingFilter.setEncoding("UTF-8");
encodingFilter.setForceEncoding(true);
FilterRegistration.Dynamic characterEncodingFilter = servletContext.addFilter("characterEncodingFilter", encodingFilter);
characterEncodingFilter.addMappingForUrlPatterns(null, false, "/*");
}
}
this is my maven dependency
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
(나는 자바 CONFGI을 사용하고 있습니다) 내 초기화 응용 프로그램입니다
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
하지만 내 서버 날이 오류를 제공 “Dynamic Web Module 3.1 requires Java 1.7 or newer”
내가에서 javax.servlet-API 버전 3.1.0
어떤 Java 버전을 사용하고 있습니까? 6 세 이하인 것 같습니다. –
Java.SE 1.8을 사용하고 있습니다. – stackUser2000