简体   繁体   English

Tomcat主机配置server.xml

[英]Tomcat host configuration server.xml

I have this web.xml in my application. 我的应用程序中有这个web.xml。

<web-app>
    <filter>
        <filter-name>app</filter-name>
        <filter-class>org.apache.tapestry5.spring.TapestrySpringFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>openSessionInView</filter-name>
        <url-pattern>/app/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>app</filter-name>
        <url-pattern>/app/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>app</filter-name>
        <url-pattern>/assets/*</url-pattern>
    </filter-mapping>


     <servlet>
        <servlet-name>jersey-serlvet</servlet-name>
        <servlet-class>
            com.sun.jersey.spi.spring.container.servlet.SpringServlet
        </servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>com.package.example.restServer</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>jersey-serlvet</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
</web-app>

when I use my application in jetty works fine. 当我在码头使用我的应用程序时,效果很好。

Web application: Web应用程序:

http://localhost/app 

Api rest application: api其余应用程序:

http://localhost/rest

In produccion I use tomcat. 在produccion中,我使用tomcat。

I want to create http://www.example.com -> http://localhost/app 

and http://rest.example.com -> http://localhost/rest

My server.xml file: 我的server.xml文件:

      <Host name="www.example.com" appBase="/usr/local/tomcat/webapps/example">
        <Context path="app" docBase="."/>
      </Host>


      <Host name="rest.example.com" appBase="/usr/local/tomcat/webapps/example">
        <Context path="rest" docBase="."/>
      </Host>

When I use this config, the server return a 404 error code. 当我使用此配置时,服务器返回404错误代码。

How I can fix it? 我该如何解决?

Thanks. 谢谢。

I got that error too and just couldn't fix for a couple of weeks but somehow i have remembered that i must check the hosts file in the C:\\Windows\\System32\\drivers\\etc. 我也收到了该错误,只是无法修复几个星期,但以某种方式我记得我必须检查C:\\ Windows \\ System32 \\ drivers \\ etc中的主机文件。 When i checked that i got shocked! 当我检查时,我感到震惊! Because the file was modified by another application that i installed on my machine and the 12.0.0.1 address were showing different urls and 0.0.0.0 was showing the local host. 因为文件被我安装在计算机上的另一个应用程序修改,并且12.0.0.1地址显示了不同的URL,而0.0.0.0显示了本地主机。

If you see something like this too; 如果您也看到类似的内容; either delete everything and just leave "127.0.0.1 localhost" or, use 0.0.0.0 when making your tests on your local machine. 要么删除所有内容,只保留“ 127.0.0.1 localhost”,要么在本地计算机上进行测试时使用0.0.0.0。

I hope this helps. 我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring Jndi配置,Server.xml - Spring Jndi Configuration, Server.xml 使用spring jndi在tomcat server.xml中设置属性 - Setting a property in tomcat server.xml using spring jndi 尝试通过Intellij IDEA部署tomcat服务器并获得一个奇怪的缺少server.xml错误 - Trying to deploy tomcat server through Intellij IDEA and getting a weird missing server.xml error java spring问题:即使编辑了server.xml文件,项目也无法在tomcat服务器上运行? - java spring problem : project can not run on tomcat server even though edited the server.xml file? 如何从Spring项目覆盖Tomcat的server.xml文件 - How to override server.xml file fo tomcat from spring project Spring,Tomcat尝试在server.xml中设置Context URL路径,但它无法正常工作 - Spring, Tomcat trying to set Context URL path in server.xml and it's not working Cloud Foundry Java Buildpack:如何为Tomcat更改server.xml中的值? - Cloud Foundry Java Buildpack : how to change value in server.xml for Tomcat? 在server.xml之外定义上下文时遇到问题 - Trouble defining context outside of server.xml 如何查看谁从server.xml文件登录? - How to see who's logged in from server.xml file? 无法加载Tomcat服务器配置 - Could not load the Tomcat server configuration
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM