@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\DELETE