【问题标题】:Tomcat mapping URLs wrongTomcat 映射 URL 错误
【发布时间】:2014-10-10 00:59:24
【问题描述】:

我在 TomCat server.xml 中编辑了 上下文路径,因此我的 webapps/app 在 mysite.com(不是 mysite.com/app)上显示为根应用程序而不是 TomCat 应用程序。在我的应用程序中,我有一些正确显示的 .jsp 文件(mysite.com/main、/register),但有些网站给了我 404 错误(mysite.com/home、/rxmsg、/signout)。 然而,当我访问 mysite.com/app/home 时,一切正常

每个这样的 URL 在本地都可以完美运行(localhost:8080/home)

我的 git 推送通过 jenkins 转移到 tomcat_home/webapps/

是什么导致一些 url 到 404?

重定向由

return "redirect:main"; //URL is changing

return "main"; //URL not changing

【问题讨论】:

    标签: spring tomcat jenkins tomcat8


    【解决方案1】:

    我设法找到了问题 在我的 tomcat server.xml 中更改了

    <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
    

    <Host name="mysite.com"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
    

    并重新启动我的服务。

    但是这样做,我现在无法在 localhost 上测试我的代码。

    【讨论】:

      【解决方案2】:

      只需创建两个 Host 标签并将 localhost 设置为 Engine 标签中的默认主机:

      <Engine defaultHost="localhost" ...
      

      【讨论】:

      • 添加另一个主机标签后,mysite.com 工作正常,但 IntelliJ 给出错误 'Application Server was not connected before run configuration stop, reason: javax.management.InstanceNotFoundException: Catalina:type=Server'
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-11-24
      • 1970-01-01
      • 2016-10-28
      • 1970-01-01
      • 2012-07-18
      • 2014-06-17
      • 2011-04-13
      相关资源
      最近更新 更多