要运行更复杂的REST程序,需要chrome插件或者专门的客户端
package com.mkyong.common.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@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";
}
}
list.jsp
<html>
<body>
<h1>Spring 3 MVC REST web service</h1>
<h3>Movie Name : ${movie}</h3>
</body>
</html>
mvc-dispatcher-servlet.xml
<context:component-scan base-package="com.mkyong.common.controller" />
<mvc:annotation-driven />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
源代码:http://pan.baidu.com/share/link?shareid=2465317834&uk=3878681452