我有下面的项目类别
@XmlRootElement(name = "item") public class Item {
private String description;
private long price;//setter getter method }
Ans ItemList 类
@XmlRootElement(name = "listing") @XmlAccessorType(XmlAccessType.FIELD) @NoJackson
public class ItemList {
private List<Item> items;// getter mothod }
项目的服务类别
@Path("user") public class ItemService extends Application {
@GET
@Path("itemList")
@Produces("application/xml")
public ItemList getCollItems(@Context HttpServletRequest request) {
ArrayList list = new ArrayList();
Item item1 = new Item("computer",2500);
Item item2 = new Item("chair",100);
Item item3 = new Item("table",200);
list.add(item1);
list.add(item2);
list.add(item3);
return new ItemList(list);
}
}
Web.xml
<context-param>
<param-name>javax.ws.rs.core.Application</param-name>
<param-value>com.service.ItemService</param-value>
</context-param>
<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<servlet>
<servlet-name>resteasy-servlet</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>resteasy-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
听着,我写了 url :- localhost:port/appNAME/ rest/user/itemList它不能正常工作,但它会给出错误HTTP Status 404 - /rest/user/itemList
请告诉我我真正缺少什么......?