在request接收中用getParameter方法得到的数据类型可能是字符串类型。
在使用前进行相应的转换。
对于Rodeo,text类型的内容进行接收的时候用:
String a=request.getParameter();
对于Checkbox类型进行接收时采用:
String[] a=request.getParameterValues("checkboxname");
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
对于cookie:
对于Cookie的操作首先是:
1.Cookie _cookie=new Cookie("username","name");(名字,内容)
2.cookie.setPath("/");
/*
cookie.setPath("/");之后,可以在webapp文件夹下的所有应用共享cookie,
而cookie.setPath("/webapp_b/"); 是指应用设置的cookie只能在webapp_b应用下的获得,
即便是产生这个cookie的webapp_a应用也不可以。
*/
3._cookie.setMaxAge(10*60);//设置COOKIE时间(以秒为单位)
4.response.addCookie(_cookie);//将cookie保存到客户端
读取cookie:
Cookie[] cookie1=request.getCookies();//客户端传来的cookie是数组类型,需要遍历找到你需要的
cookie1.getName()//获取cookie的名字
cookie1.getValue()//获取cookie的值