2012-09-04 52 views
1

我在我的應用程序中有這個web.xml。Tomcat主機配置server.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> 

當我在碼頭使用我的應用程序工作正常。

Web應用程序:

http://localhost/app 

阿比支架應用:

http://localhost/rest 

在produccion我使用Tomcat。

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

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

我的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> 

當我使用這個配置,服務器返回404錯誤代碼。

我該如何解決它?

謝謝。

+0

您是使用tomcat作爲獨立服務器,還是您有apache,並通過代理ProxyPass轉發您的呼叫?你得到一個tomcat 404或一個Apache 404?如果你得到一個Apache的問題可能是由於你的Apache配置。 – joostschouten

+0

我只使用tomcat。 – Ping

回答

0

我也得到了這個錯誤,只是不能修復幾個星期,但不知何故,我記得我必須檢查在C:\ Windows \ System32 \ drivers \等主機文件。當我檢查我感到震驚!由於該文件是由我安裝在我的計算機上的另一個應用程序修改的,並且12.0.0.1地址顯示了不同的URL,0.0.0.0顯示了本地主機。

如果你也看到類似的東西,要麼刪除所有內容,只要保留「127.0.0.1 localhost」,或者在本地機器上進行測試時使用0.0.0.0。

我希望這會有所幫助。

相關問題