一. 设置编码
request编码:
req.setCharacterEncoding("utf-8");
response编码:
resp.setCharacterEncoding("utf-8");
二. 设置ContentType
resp.setContentType("application/json;charset=utf-8");
三. 销毁Session
通过request获取session
HttpSession session = req.getSession();
销毁session
req.getsession().invalidate();
四. 获取请求地址
获取根目录
String requestURI = request.getRequestURI();
获取网址:
StringBuffer requestURL = request.getRequestURL();
请登录之后再进行评论