我试图运行嵌入式Jetty服务器并将Spring MVC应用程序部署到其中,但存在资源映射问题 - 特别是我无法映射spring mvc控制器以便它可以找到我的JSP。Spring MVC在部署到嵌入式Jetty 8服务器时无法找到JSP
配置:
码头,8.1.8.v20121106
春3.2
Jetty服务器配置:
Server server = new Server();
ServletContextHandler context = new ServletContextHandler();
//WebAppContext context = new WebAppContext();
context.setBaseResource(Resource.newClassPathResource("webapp"));
context.setClassLoader(Thread.currentThread().getContextClassLoader());
context.setContextPath("/");
AnnotationConfigWebApplicationContext webAppContext = new AnnotationConfigWebApplicationContext();
webAppContext.register(WebFaceSpringConfiguration.class);
webAppContext.setServletContext(context.getServletContext());
webAppContext.setParent(applicationContext);
context.addServlet(new ServletHolder(new DispatcherServlet(webAppContext)), "/");
server.setHandler(context);
server.setConnectors(jettyConnectors);
文件夹webapp在classpath中,但在这样的配置中,我有一个错误访问/WEB-INF/pages/main-page.jsp时出现问题(它实际上位于webapp下)。因此调用控制器方法,但视图无法解析。
我试图使用WebAppContext和Spring Dispatcher Servlet(/ *)的通配符映射,但它没有帮助 - 控制器映射被忽略或JSP无法找到。
2013-04-26
viator
+0
你可以发布你的错误? –
2013-04-26 13:25:02