[英]Invoking the resource of REST Web service
我正在寫一個 REST Web 服務。 這是 Web 服務的片段:
@Path("/first")
public class InitialResource
{
@GET
@Path(value="/{input}/{location}/{category}/{session}")
@Produces({"application/xml", "text/html"})
public List<Message> getMessage(@PathParam("input") String input, @PathParam("location") String location, @PathParam("category") String category, @PathParam("session") String session) throws NotFoundException
{
if(date.recentUpdate(location) == false)// if false, the checking of category update was run later than 1 hour ago
{
user.dropTable(); // invokes method which checks if you need to drop any user's intermediate results table
if(version.getVersion(location)== true) // if version of category did not change
{
}
else
{// version of category old; updates list of category for a specific country
updateCategory.getCategoryList(id.getSiteId(location));
}
}
return search.runSearch(input, location, category, session.split("\\.")[1]);
}
}
如果你通過這個 URI 調用它
http://localhost:8080/Project/resources/first/cat/EBAY-IE/1/0.123
你得到 404 HTTP 錯誤。
下面還有一個資源。
@GET
@Produces("text/html")
public String getMess( ) {
return "hello";
}
如果您使用此 URI 調用服務
http://localhost:8080/Project/resources/first
你會在屏幕上看到“hello”字符串。 為什么我不能調用具有指定路徑的第一個資源?
感謝您的建議,盡管問題出在其他地方。 我通過客戶端(瀏覽器)訪問 Web 服務時遇到 HTTP 404 錯誤。 使用 URI 我只是無法連接到服務器。 我只需要更新端口。 然后我更新了客戶端代碼(Javascript)訪問服務的路徑。 服務體系運行良好。 謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.