【发布时间】:2016-07-06 10:21:06
【问题描述】:
我正在尝试重载 Spring 控制器的 RequestMapping。控制器将 POST 作为请求方法,我需要传递不同的参数来重载它。
如何在不更改 URL 的情况下做到这一点?
@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;
}
【问题讨论】:
标签: spring spring-mvc spring-boot