我是Jersey Rest Framework的新手,我写了一个简单的演示来学习这项技能。这是我的问题:我试图用这个URL ---
来达到我的helloworldhttp://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!!!");
}
}
和我
答案 0 :(得分:1)
关于这个“dint work”的更多细节会很好 对于初学者 - 尝试将您的路径改为类名
@Path("/query")
答案 1 :(得分:0)
我想在这里你返回字符串。所以你不能把产品类型作为 xml ,试试这个
@Stateless
@Path("query")
public class QueryApi {
@Path("/helloworld")
@GET
@Produces({MediaType.APPLICATION_JSON})
public String test(){
return new String("Hello World!!!");
}
}