java獲取cookie的方法 java如何取得http自定義的頭部信息?
java如何取得http自定義的頭部信息?void doPost(HttpServletRequest req,HttpServletResponse resp)拋出ServletException,
java如何取得http自定義的頭部信息?
void doPost(HttpServletRequest req,HttpServletResponse resp)拋出ServletException,IOException{ 枚舉enum1=所需標題名稱() 日志.調(diào)試(“---------------頭---------------->”) 而(enum1.hasMoreElements()){ 字符串鍵=(字符串)enum1.nextElement() 字符串值=請求獲取標題(鍵) 日志.調(diào)試(鍵“:”值) } 日志.調(diào)試(“<-----header-------)”}這樣,你就可以得到頭部的信息
這個原理就像一個搜索引擎。首先得到網(wǎng)頁的源代碼,然后通過正則表達式得到手機號、電子郵件等。下面的功能是獲取網(wǎng)頁的源代碼,然后你就可以通過正規(guī)的方式獲取網(wǎng)頁中的手機號了!public void getUrlContent(){StringBuffer is=new StringBuffer()嘗試{URL myUrl=new URL(startUrl)BufferedReader br=new BufferedReader(new InputStreamReader(myUrl.openStream()))字符串s while((s=br.讀線()) !=空){是.append(s) }URL內(nèi)容=是.toString()}捕獲(異常e){系統(tǒng)輸出打?。ā癠RL file failed to output”)e.printstacktrace()}}