我在
下面有项目类 @XmlRootElement(name = "item") public class Item {
private String description;
private long price;//setter getter method }
Ans ItemList Class
@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>
听到,我写了网址: - localhost:port / appNAME / rest / user / itemList 它运行不正常但会出错 HTTP状态404 - / rest / user / itemList
请告诉我实际上缺少的是什么......?