How to pass model attributes from one Spring MVC controller to another controller?

后端 未结 10 1336
暗喜
暗喜 2020-11-27 13:19

I am redirecting from a controller to another controller. But I also need to pass model attributes to the second controller.

I don\'t want to put the model in sessi

10条回答
  •  死守一世寂寞
    2020-11-27 13:46

    I used @ControllerAdvice , please check is available in Spring 3.X; I am using it in Spring 4.0.

    @ControllerAdvice 
    public class CommonController extends ControllerBase{
    @Autowired
    MyService myServiceInstance;
    
        @ModelAttribute("userList")
        public List getUsersList()
        {
           //some code
           return ...
        }
    }
    

提交回复
热议问题