@@ -0,0 +1,788 @@
+package main.java.util;%0A%0Aimport javax.servlet.http.HttpServletRequest;%0A%0Aimport main.java.bo.UserBo;%0Aimport main.java.constant.SessionAttributeConst;%0A%0A/**%0A * %E4%B8%BB%E8%A6%81%E6%8F%90%E4%BE%9B Servlet %E4%B8%AD%E5%B8%B8%E7%94%A8%E7%9A%84 %E8%BE%93%E5%87%BA%E3%80%81%E8%8E%B7%E5%8F%96%E5%AF%B9%E8%B1%A1 %E7%AD%89%E6%93%8D%E4%BD%9C%E3%80%82%3Cbr%3E%0A * %E4%B8%80%E8%88%AC%E9%9C%80%E8%A6%81 HttpServletRequest/HttpServletResponse %E5%8F%82%E6%95%B0%0A */%0Apublic class ServletUtil %7B%0A%09/**%0A%09 * %E8%8E%B7%E5%8F%96 %E5%B7%B2%E7%99%BB%E5%BD%95%E7%9A%84%E7%94%A8%E6%88%B7%E5%AF%B9%E8%B1%A1%0A%09 * @param request doGet/doPost %E4%B8%AD%E7%9A%84 HttpServletRequest %E5%AF%B9%E8%B1%A1%0A%09 * @return %E5%B7%B2%E7%99%BB%E5%BD%95%E7%9A%84%E7%94%A8%E6%88%B7%E5%AF%B9%E8%B1%A1%0A%09 */%0A%09public static UserBo getLoginUser(HttpServletRequest request) %7B%0A%09%09return (UserBo) request.getAttribute(SessionAttributeConst.LOGIN_USER_FIELD_NAME);%0A%09%7D%0A%09/**%0A%09 * %E8%8E%B7%E5%8F%96 %E5%B7%B2%E7%99%BB%E5%BD%95%E7%94%A8%E6%88%B7%E7%9A%84id%0A%09 * @param request doGet/doPost %E4%B8%AD%E7%9A%84 HttpServletRequest %E5%AF%B9%E8%B1%A1%0A%09 * @return %E5%B7%B2%E7%99%BB%E5%BD%95%E7%94%A8%E6%88%B7%E7%9A%84id%0A%09 */%0A%09public static int getLoginUserId(HttpServletRequest request) %7B%0A%09%09return (int) request.getAttribute(SessionAttributeConst.LOGIN_USER_ID_FIELD_NAME);%0A%09%7D%0A%7D%0A

添加 Servlet工具类，提供 获取登录用户对象、登录用户id 方法