Interface ServletRequest 这是设置编码的方法 void setCharacterEncoding(java.lang.String env) Overrides the name of the character encoding used in the body of this request. 这是放到session的方法Interface HttpServletRequest 我们一般使用的是这个request 里面有个方法 getsession() HttpSession getSession() Returns the current session associated with this request, or if the request does not have a session, creates one. 这哥使我们常用的session Interface HttpSession 里面的 void setAttribute(java.lang.String name, java.lang.Object value) Binds an object to this session, using the name specified. 即可保存对象到session下面的语句即调用session保存对象的request.getSession().setAttrubute(java.lang.String name, java.lang.Object value);
request.setCharacterEncoding("gbk"); String username = request.getAttribute("name"); String password = request.getAttribute("password"); User u = new User(username,password); request.getSession().setAttribute("userInfo",u);
这是设置编码的方法
void setCharacterEncoding(java.lang.String env)
Overrides the name of the character encoding used in the body of this request.
这是放到session的方法Interface HttpServletRequest 我们一般使用的是这个request
里面有个方法 getsession()
HttpSession getSession()
Returns the current session associated with this request, or if the request does not have a session, creates one.
这哥使我们常用的session
Interface HttpSession
里面的
void setAttribute(java.lang.String name, java.lang.Object value)
Binds an object to this session, using the name specified. 即可保存对象到session下面的语句即调用session保存对象的request.getSession().setAttrubute(java.lang.String name, java.lang.Object value);
request.setCharacterEncoding("gbk");
String username = request.getAttribute("name");
String password = request.getAttribute("password");
User u = new User(username,password);
request.getSession().setAttribute("userInfo",u);