Java的REST框架 SerfJ

fmms 13年前發布 | 25K 次閱讀 Java Web框架

SerfJ 是一個最簡單的框架用來開發Java的REST的Web應用。可幫助你開發優雅的MVC架構的應用,使用慣例重于配置的思路,無需配置文件和注解。

public class Bank extends RestController {
    @GET
    public void index() {
        // By default, this action redirects to index.jsp (or index.html or index.htm)
    }

@GET
public void show() {
    // Gets ID from URL /banks/1
    String id = this.getId("bank");

    // By default, this action redirects to show.jsp (or show.html or show.htm)
}

@GET
public void newResource() {
    // By default, this action redirects to new.jsp (or new.html or new.htm)
}

@GET
public void edit() {
    // By default, this action redirects to edit.jsp (or edit.html or edit.htm)
}

@POST
public void create() {
    // By default, this action redirects to create.jsp (or create.html or create.htm)
}

@PUT
public void update() {
    // Gets bank's ID
    String id = this.getId("bank");

    // ... or another way to get the main Id
    String bankId = this.getId();

    Bank bank = // Code that gets the bank object      

    // Gets new name for the bank
    String name = this.getStringParam("name");

    // Updating the bank
    // ... Code that updates the bank's information

    // By default, this action redirects to update.jsp (or update.html or update.htm)
}

@DELETE
public void delete() {
    // By default, this action redirects to delete.jsp (or delete.html or delete.htm)
}

@GET
public void someAction() {
    // By default, this action redirects to someAction.jsp (or someAction.html or someAction.htm)
}

}</pre>

項目主頁:http://www.baiduhome.net/lib/view/home/1323606260968

 本文由用戶 fmms 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!