[英]From jersey rest application, I can't get the right URL
我是Jersey Rest Framework的新手,並且編寫了一個簡單的演示來學習此技能。 這是我的問題:我嘗試使用此URL進入我的世界-
http://localhost:8080/PayInterface/query/helloworld
但是沒有用 你能告訴我我做錯了什么嗎? 我寫了一堂課:
@Component
//Declaring that all it will handle all requests starting by /TestCaseDto
@Path("query")
public class QueryApi {
@Path("/helloworld")
@GET
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public String test(){
return new String("Hello World!!!");
}
}
和我
關於此“精干工作”的更多細節會很好
對於初學者-嘗試像這樣在類名上方更改路徑
@Path("/query")
我認為在這里您返回字符串。 所以你不能給產生類型為xml ,試試這個
@Stateless
@Path("query")
public class QueryApi {
@Path("/helloworld")
@GET
@Produces({MediaType.APPLICATION_JSON})
public String test(){
return new String("Hello World!!!");
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.