1.jsp:
username:<input type="text" name="username"><br>
password:<input type="password" name="password"><br>
2.在action中获取到jsp页面传递的值:
HttpServletRequest request = ServletActionContext.getRequest();
String username = request.getParameter("username");
String password = request.getParameter("password");
3.在Interceptor中获取action中的username
首先,在action中,需要将username存放到session中:
request.getSession().setAttribute("username", username);
在Interceptor中,通过session获取到action中的username:
String username = (String) ServletActionContext.getRequest().getSession().getAttribute("username");