mvc模式下restful风格接口

@Controller
@RequestMapping("/hello")
public class OperationLogController{
	@RequestMapping(value = "/hello", method = RequestMethod.POST,produces={"application/json;charset=UTF-8"})
	public @ResponseBody Object insert(String str) {
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("result", "true");
		return jsonObject;
	}
	@RequestMapping(value = "/hello", method = RequestMethod.GET,produces={"application/json;charset=UTF-8"})
	public @ResponseBody Object query(String str) {
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("rows","hello");
		return jsonObject;
	}
}

mvc模式下,restful风格区别于struts不须要在配置文件单独开辟通道,利用注解直接书写拦截地址就行,对应CURD操做,设置不一样的请求方式,POST\GET\PUT\DELETEjava