spring - Overload Post RequestMapping -
i trying overload requestmapping of spring controller. controller got post request method , need pass different params overload it.
how this, without changing 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; }
you can use params
option in annotation @requestparam
, this:
@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; }
maybe not work you, can check params
manual in spring.
Comments
Post a Comment