2013-02-19 54 views
0

我正在通過本教程進行工作:http://www.vogella.com/articles/REST/article.html#installation在web.xml中定義正確的資源路徑?

而且我不明白它說「此屬性必須指向您的資源類的行」。這是從這一步:

5.3. Define Jersey Servlet dispatcher 
You need to register Jersey as the servlet dispatcher for REST requests. Open the file web.xml and modify the file to the following. 

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> 
    <display-name>de.vogella.jersey.first</display-name> 
    <servlet> 
    <servlet-name>Jersey REST Service</servlet-name> 
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> 
    <init-param> 
     <param-name>com.sun.jersey.config.property.packages</param-name> 
     <param-value>de.vogella.jersey.first</param-value> 
    </init-param> 
    <load-on-startup>1</load-on-startup> 
    </servlet> 
    <servlet-mapping> 
    <servlet-name>Jersey REST Service</servlet-name> 
    <url-pattern>/rest/*</url-pattern> 
    </servlet-mapping> 
</web-app> 
The parameter "com.sun.jersey.config.property.package" defines in which package jersey will look for the web service classes. This property must point to your resources classes. The URL pattern defines part of the base URL your application will be placed. 

我已經把球衣瓶放入我的WEB-INF/lib文件夾。那麼我可以使用教程中提供的路徑還是應該使用別的東西?

回答

1

他在描述com.sun.jersey.config.property.package屬性。這應該是包含項目中REST資源的包。這與將Jersey庫添加到lib文件夾無關。他在教程的第7.3節中得到了這一點。只要你把你的REST類放在同一個包中,你可以保持原樣。

+0

謝謝。仍然不適合我,我想也許這是問題。 – 2013-02-19 18:06:34