我试图采用我在网上找到并部署到GlassFish 4.0的简单REST示例.我正在使用Eclipse(OEPE发行版)和GlassFish 4.0.当我尝试"运行为 - >在服务器上运行"时,REST示例似乎已部署,但我立即获得HTTP状态404 - 当Eclipse尝试联系我的上下文根时,在Eclipse中找不到错误(http://localhost:8080/RESTFullWS/
).
根据我一直在阅读的内容,所有内容似乎都已到位,但我仍然无法从浏览器中访问上下文根或服务端点.我想我在这里遗漏了一些明显的东西,但不确定发生了什么.
服务:
package com.example.rest; @Path("UserInfoService") public class UserInfo { @GET @Path("/name/{i}") @Produces(MediaType.TEXT_XML) public String userName(@PathParam("i") String i) { String name = i; return "" + " "; } @GET @Path("/age/{j}") @Produces(MediaType.TEXT_XML) public String userAge(@PathParam("j") int j) { int age = j; return "" + name + " " + "" + " "; } }" + age + " " + "
在glassfish-web.xml中定义的Web上下文:
http://localhost:8080/RESTFullWS/UserInfoService/name/bob -- gets me the 404. /RESTFullWS
我的服务是否正确部署?我该怎么测试?