標籤:style class c code http a
上午:老師首先回顧了昨天作業。
首先在安卓工程中的TOOLS檔案中,解析位元組流那裡,不用改變,而是把伺服器端的編碼方式變為UTF-8,然後將在安卓工程的LoginActivity類中的USERNAME給他強制轉換下。
總結一句話:如果一個字元通過某個編碼轉換成位元組碼之後,那你在轉換的時候必須拿到轉換之前的位元組碼補充:如何改變mysql串連工具的編碼方式:jdbc:mysql://localhost:3306/databasename?useUnicode=true&characterEncoding=UTF-8 問號後面加上那個就行了
如果是hibernate的話配置到<property name="connection.url">裡面
mysql不支援中文,不過取出來的時候是可以還原成中文的.
然後講了比HttpUrlConnection更簡單快捷的方法來完成對伺服器的互動。
一個方法new的誰,就執行誰的方法,如果在方法中使用了SUPER關鍵字調用其父親的方法,那麼就先執行父親,如果父親的方法也使用了SUPER,那麼一次先執行,父親的父親的方法
然後注意一個網站GitHub,以下是從這個網站上面翻譯過來的HttpClient相關內容: Features
- Make asynchronous HTTP requests, handle responses in anonymous callbacks
- HTTP requests happen outside the UI thread
- Requests use a threadpool to cap concurrent resource usage
- GET/POST params builder (RequestParams)
- Multipart file uploads with no additional third party libraries
- Tiny size overhead to your application, only 25kb for everything
- Automatic smart request retries optimized for spotty mobile connections
- Automatic gzip response decoding support for super-fast requests
- Binary file (images etc) downloading with
BinaryHttpResponseHandler
- Built-in response parsing into JSON with
JsonHttpResponseHandler
- Persistent cookie store, saves cookies into your app’s SharedPreferences
特性
進行非同步HTTP請求,處理響應在匿名回調
HTTP請求發生在UI線程
請求使用threadpool帽並發資源使用方式
GET / POST參數構建器(RequestParams)
多部分檔案上傳,沒有額外的第三方庫
小尺寸應用程式開銷,只有25 kb為我所做的一切
自動智能移動串連請求重試最佳化參差不齊
自動解碼支援gzip反應速度超快的請求
二進位檔案(圖片等)與BinaryHttpResponseHandler下載
內建的解析與JsonHttpResponseHandler JSON響應
持久化cookie儲存、儲存cookie到你的應用程式的SharedPreferences