Servlets SpringMVC在部署到嵌入式Jetty8服务器时找不到JSP

Servlets SpringMVC在部署到嵌入式Jetty8服务器时找不到JSP,servlets,spring-mvc,jetty,embedded-jetty,Servlets,Spring Mvc,Jetty,Embedded Jetty,我试图运行嵌入式Jetty server并将Spring MVC应用程序部署到其中,但存在资源映射问题——特别是我无法映射Spring MVC控制器,以便它可以找到我的JSP 配置: 码头-8.1.8.v20121106 春季3.2 Jetty服务器配置: Server server = new Server(); ServletContextHandler context = new ServletContextHandler(); //WebAppContext

我试图运行嵌入式Jetty server并将Spring MVC应用程序部署到其中,但存在资源映射问题——特别是我无法映射Spring MVC控制器,以便它可以找到我的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下)时遇到错误。所以调用了控制器方法,但无法解析视图


我尝试对Spring Dispatcher Servlet(/*)使用WebAppContext和通配符映射,但没有帮助-忽略控制器映射或找不到JSP。

您需要指定一个viewresolver,这在xml中是正常的

 <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"
          p:prefix="/WEB-INF/pages/" p:suffix=".jsp"/>


实际上我有一个。而且它看起来是活动的,因为我的控制器方法返回“主页”视图名,但错误包含jsp文件的完整路径。@viator我不熟悉jetty。。。对不起可以;我帮不了你了,你能把你的错误发出去吗?