提交 2ef77f3c 编写于 作者: nich_olas's avatar nich_olas

生产代码片段

上级 00470cde
class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
public class LoginInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// 判断用户是否登录,这里使用 sa-token 提供的方法进行判断
if (StpUtil.isLogin()) {
return true; // 已登录,放行
} else {
// 未登录,重定向到登录页
response.sendRedirect("/login");
return false;
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册