【问题标题】:Spring web app not starting in jetty serverSpring Web 应用程序未在码头服务器中启动
【发布时间】:2025-11-24 17:10:01
【问题描述】:

我有一个使用 Eclipse IDE 开发的简单 Spring Web 应用程序项目。当我使用码头服务器运行项目时,服务器启动。然后我尝试使用详细信息进入上下文,它显示以下错误 404。

这是我定义起始屏幕的 web.xml 文件。

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>TouchPOS</display-name>
  <servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.html</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>layout.html</welcome-file>
  </welcome-file-list>
</web-app>

这是项目资源。

我在这里做错了什么?启动服务器时没有异常。请帮我!

我查看了控制台并给出了以下错误!我该如何解决这个问题!

    WARNING: No mapping found for HTTP request with URI [/TouchPOSApplication/layout.html] in DispatcherServlet with name 'dispatcher'
Apr 19, 2013 10:53:48 AM org.springframework.web.servlet.PageNotFound noHandlerFound

mvc 配置文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">

    <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
</beans>    

【问题讨论】:

  • 你的mvc-config 和控制器是什么样子的?
  • 尝试使用&lt;mvc:resources/&gt; 并查看更多信息:static.springsource.org/spring/docs/3.0.x/…
  • 我已经更新了 mvc-config 文件!
  • 我同意@NoobUnChained。这可能是一个静态资源问题。您的 servlet url 模式与您的静态 layout.html 文件“冲突”。
  • 我该如何解决这个问题!我用 / 替换了 *.html 仍然没有运气!

标签: java web-applications spring-mvc jetty


【解决方案1】:

您确定您的应用程序在您希望它运行的 webapp 上下文路径中运行吗?您的 war 文件的名称是什么?您是否为配置上下文路径的 web 应用提供了 jetty context.xml 文件?

如果不是,则尝试使用war文件的名称作为上下文路径:

例如:

如果战争的名称是“webapps/touchpos.war”,请尝试"http://localhost:8080/touchpos/"

【讨论】:

    最近更新 更多