标签:import app content rate php 请求 rip alert info
本文参考 https://blog.csdn.net/qq_34608620/article/details/80635139
解决方法:
一、前端,data: JSON.stringify(excelRelated.chooseData), 直接传送json字符串
$.ajax({
//这里是php的url格式
url: "http://127.0.0.1:8081/source/downloadExcel",
type: "post",
contentType : ‘application/json; charset=UTF-8‘,
data: JSON.stringify(excelRelated.chooseData),
dataType: ‘json‘,
success: function (data) {
alert(111)
}
})
二、后台
封装成实体类对象
1 package com.yyc.entity; 2 3 import java.util.List; 4 5 public class CoursePackage { 6 7 public CoursePackage() { 8 // TODO Auto-generated constructor stub 9 } 10 11 private Course course; 12 13 private List<CourseInfo> courseInfoList; 14 15 public void setCourse(Course course) 16 { 17 this.course = course; 18 } 19 20 public void setCourseInfoList(List<CourseInfo> courseInfoList) 21 { 22 this.courseInfoList = courseInfoList; 23 } 24 25 public Course getCourse() 26 { 27 return course; 28 } 29 30 public List<CourseInfo> getCourseInfoList() 31 { 32 return courseInfoList; 33 } 34 35 }
controller对应代码
1 @RequestMapping(method = RequestMethod.POST ,consumes = "application/json") 2 public String createCourse(@RequestBody CoursePackage coursePackage) 3 { 4 System.out.println(coursePackage.getCourse()); 5 System.out.println(coursePackage.getCourseInfoList()); 6 return "/createCourse"; 7 }
controller函数中参数列表使用多个@RequestBody
标签:import app content rate php 请求 rip alert info
原文地址:https://www.cnblogs.com/zhangwensi/p/11797768.html