springboot跳转问题

原创
2018/10/29 10:21
阅读数 612

springmvc时,跳转可以这样写:

if (jump != null && StringUtils.isNotBlank(jump)) {
	return new ModelAndView("redirect:" + jump);
} else {
	return new ModelAndView("redirect:/index.html");
}

但在springboot里这样写不行,会报错,找不到视图,应该改为下面的方式:

if (StringUtils.isNotBlank(jump)) {
    view.setView(new RedirectView(jump, false));
	return view;
} else {
    view.setView(new RedirectView("/index.html", false));
    return view;
}

 

展开阅读全文
加载中

作者的其它热门文章

打赏
0
0 收藏
分享
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部