5
Grizzly v2.1.9
을 Jersey
과 Spring
으로 성공적으로 통합했습니다. 그러나 Grizzly
을 2.2.19
으로 마이그레이션하려고 할 때 작동하지 않을 수 있습니다.통합 저지와 스프링이있는 Grizzly2.2.X
Grizzly v2.1.9
의 원본 코드는 다음과 같습니다.
HttpServer server = new HttpServer();
NetworkListener listener = new NetworkListener("grizzly2", "localhost", 3388);
server.addListener(listener);
ServletHandler sa = new ServletHandler();
sa.setContextPath("/");
sa.setServletInstance(new SpringServlet());
sa.addContextParameter("contextConfigLocation", "classpath:spring-context.xml");
sa.addServletListener("org.springframework.web.context.ContextLoaderListener");
sa.addServletListener("org.springframework.web.context.request.RequestContextListener");
ServerConfiguration config = server.getServerConfiguration();
config.addHttpHandler(sa, new String[] {"/"});
server.start();
그리고 Grizzly v2.2.19
갖는 새로운 코드
HttpServer server = new HttpServer();
NetworkListener listener = new NetworkListener("grizzly2", "localhost", 3388);
WebappContext ctx = new WebappContext("ctx","/");
final ServletRegistration reg = ctx.addServlet("spring", new SpringServlet());
reg.addMapping("/*");
ctx.addContextInitParameter("contextConfigLocation", "classpath:spring-context.xml");
ctx.addListener("org.springframework.web.context.ContextLoaderListener");
ctx.addListener("org.springframework.web.context.request.RequestContextListener");
ctx.deploy(server);
server.start();
새로운 코드 아래와 같다 컴파일 않고, 예외로 실행될 수있다. 그러나 Jersey
에 의해 다른 방법으로 전달되어야하는 모든 URL은 이제 모두 기본 페이지 "/"로 전달됩니다. 같은 문제를 충족하는 사람을
UPDATE
. Grizzly2.2.20