Java的REST框架 SerfJ
fmms
13年前
SerfJ 是一个最简单的框架用来开发Java的REST的Web应用。可帮助你开发优雅的MVC架构的应用,使用惯例重于配置的思路,无需配置文件和注解。 <br /> <pre class="brush:java; toolbar: true; auto-links: false;">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> <br /> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1323606260968" target="_blank">http://www.open-open.com/lib/view/home/1323606260968</a></p>