1.vue.js uses axios to send requests to the background. The passing parameters include an object, and a string.
object to the background with javaBean, and String to the background with String.
2. The foreground code is as follows:
data() {
return {
sCompanyData: {
id: undefined,
zhName: "",
usName: "",
socialCreditCode: "",
organisationNo: "",
registerNo: ""
},
flag: "declare"
};
},
methods: {
sCompanySave() {
this.$refs["childrenForm"].validate(valid => {
//
if (valid) {
axios.post("/htrt/compManager/sCompanySave", {
dto: this.sCompanyData,
flag: flag
}).then(resp => {
if (resp.data.success == false) {
this.$alert(resp.data.errorMsg, "", {
confirmButtonText: "",
callback: action => {}
});
} else {
this.sCompanyFormVisible = false;
this.$refs["childrenForm"].resetFields();
this.getList();
}
})
.catch(err => {
console.log(
"" + err.status + "," + err.statusText
);
});
} else {
console.log("error submit!!");
return false;
}
});
}
}
3. The background java controller is as follows:
@RequestMapping(value = "sCompanySave")
@ResponseBody
public JsonResponse<CompanyManagementDto> sCompanySave(@RequestBody Map<String,Object>paraMap) {
4. The question is how to deal with the paraMap,
problem in controller in paraMap.get ("dto"). What I can see with the code is also a map, but the forced conversion to map has not been successful.
ask students if you have encountered this problem.