您的位置:首页 > Web前端 > Vue.js

前台使用Vue post请求,后台如何接收请求参数

2018-08-25 22:53 459 查看

vue代码

axios.post("DebugController/debugInterface",that.fileModal)
.then(function(res) {
that.button_isloading=false;
that.isreadOnly=false;
if (res.data.data!=null)
{
that.headData = JSON.stringify(res.data.data.head);
that.metaData = JSON.stringify(res.data.data.data);
}
else
{
that.$Notice.warning({
title: "查询出现异常,请检查",
desc: ''
});
}

})
.catch(function(err) {
console.log(err)
})

java代码
controller
方法一获得多个参数

@RequestMapping("debugInterface")
@ResponseBody
public ResultObj debugInterface(@RequestBody LinkedHashMap<String,String> params) {
ResultObj result = ResultObj.succeed();
String serverName=params.get("serviceName");
return result;
}

方法二获得单个参数
方法三获得Bean
vue代码

axios.post('RedoController/updateRedoTask', redoCondition)
.then(function(res) {
that.addModifyModal = false
that.$Notice.success({
title: 'Redo任务修改成功。',
});
that.query()
})
.catch(function(err) {
console.log(err)
})

java代码

public void updateRedoTask(RedoConditionBean redoCondition) {
RedoSvcTypeBean redoSvcType = redoCondition.getRedoSvcType();
Date date=new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
redoCondition.setModifyDate(sdf.format(date));
redoConditionMapper.update(redoCondition);
redoSvcTypeMapper.update(redoSvcType);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐