2016-07-06 3 views
0

SpringコントローラのRequestMappingをオーバーロードしようとしています。コントローラはリクエストメソッドとしてPOSTを取得しました。私はそれをオーバーロードするために別のパラメータを渡す必要があります。オーバーロードポストRequestMapping

どのように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; 
} 

答えて

1

あなたはこのように、注釈@RequestParamparamsオプションを使用することができます。

@RequestMapping(method = RequestMethod.POST, value = "/windparks/import/error", params = {"locale", "authenticatedUser", "regList", "regulations", "windparkId"}) 
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", params = {"locale", "authenticatedUser", "windparkId"}) 
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; 
} 

はたぶん、あなたのために動作しない、しかし、あなたはSpringparamsマニュアルを確認することができます。

+0

非常にうまく動作します、ありがとう! – Frossy