servlet筆記

 show2014年2月25日 星期二 天氣 雨
(1)編碼解碼(day02)
解決辦法:
方式一:
step1,要保證使用指定的編碼格式打開頁面。
比如,對於html文件,可以使用<meta http-equiv="content-type"
content="textml;charset=utf-8">
step2,在服務器,使用
request.setCharacterEncoding("utf-8");
注意:
  a,該方法必須要放在所有的request.getParameter方法的前面。
  b, 只對post請求有效。
方式二:適用於get,post請求。
  step1,要保證使用指定的編碼格式打開頁面。
  step2, new String(str.getBytes("iso-8859-1"),
  "utf-8");
(2) 數據庫
create database jd1401db default character set utf8;
use jd1301db;
create table t_emp(
id int primary key auto_increment,
name varchar(50),
salary double,
age int
);
將中文數據插入到mysql數據庫
con = DriverManager.getConnection("jdbc:mysql://localhost:33061301db?" +
"useUnicode=true&characterEncoding=utf8",







2014年2月26日  星期三 天氣 陰
(1)myql中文亂碼問題的解決
在mysql的my.in配置文件裏 把lain1設置成gbk



2014年2月28日  星期五 天氣 陰
(1)完成員工管理系統
(2)明天的任務
create table t_user(
id int primary key auto_increment,
username varchar(50) unique,
name varchar(255),
pwd varchar(30),
gender char(1)
);  
unique: 唯一性約束
(3)工廠模式(day04)




2014年3月1日  星期六 天氣 陰
(1)隱含對象(day05)
在jsp文件裏面,不用創建就可以直接使用的對象
out,request,response
(2)綁定 傳遞 數據 request


2014年3月4日  星期二 天氣 多雲
研究購物車
Session綁定最重要了

2014年3月12日
網上交友
int save(User user) 返回id 有什麼作用
2014年3月15日
Id 是爲了生成一個用戶特定的文件夾存放圖片的

regist.jsp驗證碼 後門 的 return 作用?

2014年3月17日
可以防止Cannot forward after response has been committed
再次提交

getServletContext()爲什麼可以直接用,有什麼作用?
答:getServletConfig()方法返回一個ServletConfig對象,該對象中包含servlet啓動配置信息.這個信息中包括了所有初始化參數和一個ServletContext對象.
getServletContext()返回一個ServletContext對象,該對象包含關於servlet運行環境的信息.這個方法在GenericServlet類中爲方便應用而定義的. 實際上,它從傳送到servlet的init(ServletConfig)方法中的ServletConfig對象中檢索ServletContext.


2014年3月18日
EL表達式
name:${user.name}
告訴容器,依次從
pageContext,request,session,application
查找(getAttribute)綁訂名稱爲"user"的對象。
如果找到,接下來調用getName方法並輸出。
如果找不到,會輸出""。
${user["name"]}


2014年3月21日
AJAX
方式一: get請求
xhr.open(請求方式,請求地址,同步(false)還是異步);
請求方式: 'get','post'
比如: xhr.open('get',
'check_username.do?username=zs',true);
xhr.onreadystatechange=f1;
xhr.send(null);
方式二:post請求
比如: 
xhr.open('post','check_username.do',true);
//給請求數據包添加一個content-type的消息頭
xhr.setRequestHeader('content-type',
'application/x-www-form-urlencoded');
xhr.onreadystatechange=f1;
//post請求要將請求參數加在send方法裏面
xhr.send('username=zs');
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章