[英]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.