//解决GET提交乱码
String s=new String(user.getUsername()[0].getBytes("iso8859-1"),"UTF-8");
//解决POST提交乱码
request.setCharacterEncoding("UTF-8");
servlet中赋值
request.setAttribute("data", "hello");
request.getRequestDispatcher("/index.jsp").forward(request, response);
index.jsp 中取值
<form>
<%String data = (String) request.getAttribute("data"); out.write(data); %> </form>
//包含页面
request.getRequestDispatcher("/index.jsp").include(request, response);
response.getWriter().write("12"); request.getRequestDispatcher("/index.jsp").include(request, response);
//通过referer防盗链
String referer = request.getHeader("referer");