njthnet

[导入]Spring3 REST MVC框架,提速你的Web开发

最近在Java web 项目中需要采用非常简单的REST框架,Struts2、webwork、JSF 经过一番比较,最后选择了Spring3,理由只有一个 “简单,好用,并满足需要”。很久以前就Rod Johnson大叔说 Spring3 全面支持REST风格的Web服务,"We're really seeing extensive interest and growth in REST, and it will have comprehensive support for RESTful Web services," said Johnson,今天亲自尝试了一下,真有点相识恨晚的感觉,如果在这次项目运用没有太大的问题,将来在其他项目会大量运用。 工作原理如图所示: *根据HTTP请求的URL,调用相应的DispatcherServlet控制器。 *提供一个视图是作为HTTP响应发送。 页面上最终运行效果,如图所示: 主要代码: 清单1:TopicController package com.javabloger.springrest.action; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @Controller @RequestMapping("/topic")  //url映射的名称 public class TopicController {     @RequestMapping(value = "/{id}",method=RequestMethod.GET)     public String helloWorld(             @PathVariable Long id,             HttpServletRequest request,     [...]
文章来源:http://www.javabloger.com/article/spring3-rest-mvc-example.html?source=rss

posted on 2010-04-20 15:28 njthnet 阅读(285) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

导航

<2025年7月>
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

统计

留言簿

文章档案

新闻档案

搜索

最新评论