如果发送请求的方式是get方式的话、
更改编码格式的方法是 new String (iso-8859-1,utf-8);
这个是一个一个改编码格式,比较麻烦,不推荐使用,推荐在server.xml中一次性修改。
注意:Content中增加属性URIEncoding="UTF-8"严格区分大小写。
如果是post方式的话、
利用java代码中的request.setCharacorEncoding(“UTF-8”)来更改编码。
request对象
addRedirect(Cookie cookie);服务端向客户端增加一个cookie对象。
sendRedirect(String loction) throw IOException: 重定向
重定向的时候地址栏会改变,但是会发生数据丢失。
resquest.getResquestDispatcher(“XX.jsp”).forword(request,response)
ContentType()设置编码格式。
Session 服务端和 Cookie 客户端
Cookie : name = value
javax.servlet.http.Cookie
public Cookie(Sting name,String value)
String getName()
String getValue()
void setMaxAge(int expiry) 最大有效期 秒
服务端准备Cookie:
response.addCookie(Cookie cookie)
客户端获取cookie: request.getCookies()
服务端增加cookies:response对象
客户端获取对象:request对象