//About parameter transfer acceptance
If there is this tag on the @RequestBody method, the front-end parameters (ajax) are both attribute-driven, model-driven, passed to the backend, and written on the method name, only a pair of images can be passed, not a list (so The parameter data passed by ajax can only be {}), and it can be a list written on the parameter (this is data can be [{}{}]). Use [] to declare that it is a complex format json, see below for details.
This label method returns the data of the callback function
@RequestMapping(value = "/savemobile")
@RequestBody
public int saveMobile(@RequestBody List<User> user ,@RequestParam(value = "yzm", required = false) String yzm ) {
@RequestMapping(value = "/savemobile")//
public int saveMobile(@RequestBody List<User> user ,@RequestParam(value = "yzm", required = false) String yzm) {
@RequestMapping( value = "/savemobile")//This can be
@RequestBody
public int saveMobile(@RequestBody List<User>
@ResponseBody//这种可以
public String saveMobile(@RequestParam(value = "yzm", required = false) String yzm , User user ) {
@ResponseBody//卸载外面的时候里面的只能是单个实体
public PageInfo<Role> queryPageSupplier(HttpSession session,
@RequestParam(value = "pageNo", required = false) int pageNo,
@RequestParam(value = "pageSize", required = false) int pageSize,
Role role)
@RequestMapping(value = "/savemobile")
@ResponseBody
public String saveMobile(@RequestParam(value = "yzm", required = false) String yzm , User user ) {
$.ajax({
type: "post",
url: "<%=webPath%>/system/users/savemobile.do",
data: ndata,
dataType: "json",
///////////////////// //////// contentType: "application/json", this sentence goes without list [] is a complex format flag
success: function (data) {
if (data = 1) {
alert("Binding is successful, Thank you!");
} else if (data = 0) {
alert("The operation failed, the record may no longer exist.");
} else if (data > 1) {
alert("Error, multiple records were deleted .");
}
},
error: function (textStatus) {
alert("Data load failed!!!");
}
});
========复杂格式json提交=========================
@RequestMapping(value = "/savetree")
public String saveTree( @RequestBody List<MenuDto> menuDtos, @RequestParam(value = "roleId", required = false) String roleId) {
$.ajax({
type: "post",
url: "<%=webPath%>/system/acount/savetree.do?roleId="+roleId,
data: JSON.stringify(events),
dataType: "json",
contentType:"application/json"
});
@RequestMapping(value = "/savecheck")
@ResponseBody
public String saveCheck(@RequestBody List<User> user) {//由于前台是【】不是{}
System.out.println("111");
return "redirect:index.do";
}
======================================================
Transmission of springmvc values (from foreground to background)
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326847149&siteId=291194637
Ranking