SP02---jsp内置对象-02.pptx
<%
request.setCharacterEncoding("utf-8");
String nameString="";
try{
Cookie[] cookies=request.getCookies();
if(cookies!=null){
for(int i=0;i<cookies.length;i++){
if("name".equals(cookies[i].getName()))
{ nameString=cookies[i].getValue();//读取cookie信息,得到用户名
nameString= URLDecoder.decode(nameString,"utf-8");//解码,得到中文用户名
request.setAttribute("name", nameString);
} } } }catch(Exception e){
e.printStackTrace();
}
%>

Last modification:October 6th, 2018 at 02:50 am
If you think my article is useful to you, please feel free to appreciate