java - How to call one controller method in another controller with RedirectAttributes -


code have written below.

controller1 {    @autowired    controller2 controller2    //caller method    void method1() {       controller2.furnction1(model,redirectattributes);    } }  controller2 {     public void function1(model model, redirectattributes atr){     } } 

question is: how intialize redirectattributes (redirectattributes)in new controller(controller1). controller1 not form submit, couldn't redirectattributes default.

how call funcation1 in controller2.

redirect not work here. form data lost. try forwarding request url.

try

    controller1 {     @requestmapping("url1")    public string method1() {      return "forward:/url2";    } }  controller2 {    @requestmapping("/url2")    public string function1(model model, redirectattributes atr){       //do    } } 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -