spring如何接收前端多个参数
目录
spring如何接收前端多个参数
前端使用angular5框架,像后端发送url代码
private ReportUrl = 'http://localhost:8080/report'
$Reports( from: number, to: number) {
const url = `${this.ReportUrl}?from=${from}&to=${to}`;
return this.http.post<HatchReport[]>(url, '', HTTP_OPTIONS );
}
后端用spring框架,在controller中其接收方法为
@RestController
@CrossOrigin
public class ReportController {
@Autowired
private final ReportService reportService;
public reportController(ReportService reportService) {
this.reportService = reportService;
}
@RequestMapping(value = "report", method = RequestMethod.POST)
@ResponseBody
public List<Report> Reports( Long from,Long to) {
return reportService.Reports(from, to);
}
}