通过session传递值
需要导入的包:
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
将值放入session:
HttpSession session = request.getSession();
session.setAttribute("USER_NAME",userName);
取出session中的值:
HttpSession session=request.getSession();
String username=(String)session.getAttribute("USER_NAME");