0
我想重載一個Spring控制器的RequestMapping。控制器得到POST作爲請求方法,我需要通過它不同的參數來超載它。重載Post請求映射
我怎麼能做到這一點,而無需更改網址?
@RequestMapping(method = RequestMethod.POST, value = "/windparks/import/error")
public ModelAndView handleFileUploadError(Locale locale, @AuthenticationPrincipal SpringUser authenticatedUser, List<RegulationEvent> regList, @RequestParam("regulations") MultipartFile regulations, RedirectAttributes redirectAttributes, @PathVariable String windparkId) throws IOException, WindSpeedInterpolator.TimeSeriesMismatchException, SAXException {
ModelAndView view = new ModelAndView("uis/windparks/parkdetail");
view.addObject("failedEvents", regList);
view.addObject("windparkId", windparkId);
return view;
}
@RequestMapping(method = RequestMethod.POST, value = "/windparks/import/error")
public ModelAndView handleFileUploadError(Locale locale, @AuthenticationPrincipal SpringUser authenticatedUser, RedirectAttributes redirectAttributes, @PathVariable String windparkId) throws IOException, WindSpeedInterpolator.TimeSeriesMismatchException, SAXException {
ModelAndView view = new ModelAndView("uis/windparks/parkdetail");
view.addObject("windparkId", windparkId);
return view;
}
完美地工作,非常感謝! – Frossy