示例:
@RequestMapping(value = "/passcomment",
method = RequestMethod.POST,
produces = {"application/json;charset=UTF-8"}
)
@ResponseBody
int passComment(@RequestParam("cityId") int cityId, @RequestParam("spotName")String spotName, @RequestParam("context")String context) {
logger.info("正在存储评论");
//判空处理
if(context==null||context.isEmpty()) return -1;
int result = -1;
result = recommendService.passComment(cityId,spotName,context);
if(result!=-1){
logger.info("存储成功");
}
else{
logger.info("存储失败");
}
return result;
}
@RequestParam注解的含义就是请求参数,在这里很明显是需要客户端请求时发送的参数,并且定义了发送的标识名。
如@RequestParam("cityId")表示前端在使用该POST