![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
springboot
Teemoye
终身学习
展开
-
使用重定向后拿到消息的方法
使用redirect重定向url后可以用RedirectAttributes拿到消息并将消息展示到前端 通过attributes.addFlashAttribute方法 @PostMapping("/types") public String posy(Type type, RedirectAttributes attributes){ Type type1 = typeService.saveType(type); if (type1 == null) {原创 2021-01-30 13:04:49 · 307 阅读 · 0 评论 -
Springboot拦截器实现
Springboot拦截器实现 下面展示一些 内联代码片。 如写个登录类拦截器,继承HandlerInterceptorAdapter 若user=null即无用户,response.sendRedirect("/admin")重定向到登录页面 import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; import javax.servlet.http.HttpServletRequest; import javax原创 2021-01-29 12:03:58 · 227 阅读 · 8 评论