使用struts2開發RESTful服務 |
http://www.ibm.com/developerworks/cn/java/j-lo-struts2rest/
常用的跳轉方法: index:處理不帶 id 請求參數的 GET 請求。 show:處理帶 id 請求參數的 GET 請求。 create:處理不帶 id 請求參數的 POST 請求。 update:處理帶 id 請求參數的 PUT 請求。 destroy:處理帶 id 請求參數的 DELETE 請求。 edit:處理帶 id 請求參數,且指定操作 edit 資源的 GET 請求。 editNew:處理不帶 id 請求參數,且指定操作 edit 資源的 GET 請求。 一個簡單的例子(@Action("product")@Namespace("/merchant/product")) public HttpHeaders index() { return new DefaultHttpHeaders("index").disableCaching(); } 在WEB-INF路徑+namespace的路徑下創建一個product-index.jsp頁面。