在我的练习中,我必须开发一个弹簧应用程序,应该可以通过WebGUI和REST服务访问。 现在我浏览一下Spring MVC的示例,其中有关于Spring MVC的世界教程this。弹簧Mvc Web应用程序与休息界面
控制器类似如下:
@Controller
@RequestMapping("/welcome")
public class HelloController {
@RequestMapping(method = RequestMethod.GET)
public String printWelcome(ModelMap model) {
model.addAttribute("message", "Spring 3 MVC Hello World");
return "hello";
}
}
然后我通过Spring REST example看起来像这样看:
@Controller
@RequestMapping("/movie")
public class MovieController {
@RequestMapping(value = "/{name}", method = RequestMethod.GET)
public String getMovie(@PathVariable String name, ModelMap model) {
model.addAttribute("movie", name);
return "list";
}
@RequestMapping(value = "/", method = RequestMethod.GET)
public String getDefaultMovie(ModelMap model) {
model.addAttribute("movie", "this is default movie");
return "list";
}
}
现在我想知道,怎么办这两个例子(Spring的MVC和春天休息)不同? 他们都使用相同的注释和工作类似。这不仅仅是REST的例子吗?
如何为Spring-MVC应用程序提供Rest-Interface?
问候
RESTful服务与访问资源的方式有关。请参阅:https://en.wikipedia.org/wiki/Representational_state_transfer#RESTful_web_APIs – Aurand