public void method01(HttpSession session, String str){
session.setAttribute(...)
}
public void method01(HttpServletRequest request, String str){
HttpSession session = request.getSession();
session.setAttribute(...)
}
上面两个方法:是直接使用HttpSession接口声明一个session对象好,还是声明一个HttpServletRequest对象调用request.getSession()方法好?
就结果来说,没有区别。
如果是Spring框架的Controller层,更推荐使用第一种。