【问题标题】:mvn jetty:run giving error 404mvn jetty:run 给出错误 404
【发布时间】:2014-10-22 13:05:37
【问题描述】:

我有一个 Spring MVC Web 应用程序并尝试使用 Jetty 运行它。但每当我输入

mvn 码头:运行

我得到了以“Jetty Server Started”结尾的正确事件序列

但是当我尝试打开浏览器并输入时

http:localhost:8080/app

我收到错误 404 页面未找到

这是我的 pom.xml 码头部分

<plugin>
  <!-- This plugin is needed for the servlet example -->
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>7.2.0.v20101020</version>
  <configuration>
    <webApp>
      <contextPath>/app</contextPath>
    </webApp>
  </configuration>
</plugin>

我的控制器被映射到 @RequestMapping("/") 并且我的 servlet 也被映射到 /。 pom.xml 构建名称是 app 因此 URL 是 http://localhost:8080/app

对此的任何帮助都会很棒。 我也尝试过使用 Jetty v9,但这也不起作用

【问题讨论】:

    标签: java maven spring-mvc jetty


    【解决方案1】:

    试试这个效果很好

    编辑

    <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
        <version>6.1.8</version>
           <configuration>
              <contextPath>/app</contextPath>
           </configuration>
    </plugin>
    

    第一件事http:localhost:8080/app 是错误的,它应该是http://localhost:8080/app 如果您提供此网址,那么您必须有一个可以在 web.xml 中指定的登录页面 像这样

    <welcome-file-list>
       <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    

    所以只需尝试访问 url http://localhost:8080/app/index.jsp,其中 web-content 文件夹下必须有一些 index.jsp

    【讨论】:

    • 对不起,我错过了说我也试过了,但它仍然给我同样的错误 404。我现在已经编辑了这个问题以反映这一点。谢谢
    • 谢谢@SparkOn 我试过了,但我仍然得到同样的错误:(
    • 您是否尝试使用此网址http:localhost:8080/app
    • 是的,当我使用该 UEL 时,我遇到了相同的“请求 URI 未找到错误”。 :(
    • 第一件事 http:localhost:8080/app 是错误的,它应该是 http://localhost:8080/app 如果你提供这个 url 那么你必须有一个登陆页面,你可以在 web.xml 的 中指定
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-26
    • 2012-12-04
    • 2013-04-08
    • 2016-01-03
    • 2017-06-22
    • 1970-01-01
    相关资源
    最近更新 更多