一、corejava階段
1.理解面向對象的含義及其三大特征 (繼承,封裝,多態)
封裝:使屬性(特征)私有化,外部不能直接訪問,需要訪問屬性,為外部提供公開的方法(行為)進行訪問。
繼承: 是一種是的關系,子類對父類進行擴展, 對父類的復用,java只允許單繼承。
多態: 一種事物多種形態,對象的多態,把一個對象復制給不同的引用方法的多態,重寫 重載。
2.Java是單繼承多實現的理解抽象類和接口的區別,了解四個訪問修飾符的訪問范圍(public protected default private)
單繼承:更明確,一個子類就應該是其父類代表的事物中的某個更具體的類別,不應該即是這種東西又是那種東西,而從實用角度上來說 單繼承易讀 易維護 語義清晰 邏輯清楚。
多實現:繼承的拓展,接口只定義一些公共行為 比如有兩個接口 一個定義了跑這個動作 另一個定義了走這個動作,人這個類就可以同時實現這兩個接口所定義的行為。
抽象類 (abstarct class )
抽象類都表示的是現實的事物。
抽象類所有方法是public abstarct。
抽象類跟普通類差不多,比普通類多了一些抽象方法.
抽象類只能被繼承,一個具體類繼承(extends)一個抽象類,必須實現所有 的抽象方法。(單繼承)
抽象類有構造方法 。
抽象類的構造方法給子類構造方法調用。
抽象類不能直接創建實例。
接口(interface)
接口表示的是規范。
接口里的所有屬性是public static final。
接口沒有普通方法。
接口只能被實現(implements),一個具體類實現接口,必須使用全部的抽象方法。 (多實現)
接口沒有構造方法。
接口之間可以繼承。
接口不能直接創建實例。
區別:
抽象類可以有構造方法,接口中不能有構造方法。
抽象類中可以有普通成員變量,接口中沒有普通成員變量
抽象類中可以包含非抽象的普通方法,接口中的所有方法必須都是抽象的,不能有非抽象的普通方法。
抽象類中的抽象方法的訪問類型可以是public,protected和(默認類型,雖然eclipse下不報錯,但應該也不行),但接口中的抽象方法只能是public類型的,并且默認即為public abstract類型。
抽象類中可以包含靜態方法,接口中不能包含靜態方法
抽象類和接口中都可以包含靜態成員變量,抽象類中的靜態成員變量的訪問類型可以任意,但接口中定義的變量只能是public static final類型,并且默認即為public static final類型。
-
一個類可以實現多個接口,但只能繼承一個抽象類。
同類 同包 不同包子類 不同包非子類
public (公開的) √ √ √ √
protected(受保護的) √ √ √ x
default (默認的) √ √ x x
private (私有的) √ x x x
3.了解方法重載和方法重寫的區別 重載和重寫都能體現多態
重載:
是在一個類中,方便了調用者
方法名相同,參數列表不同(參數類型不同,參數個數不同)
返回值可以相同,也可以不相同。
重寫:
是父子類之間,如果創建的是子類對象,
調用重寫的方法,執行的是子類的,
方法名相同,返回類型相同,參數列表相同,
拋出的異常不能更大,訪問權限不能更小。
4.熟悉String類 并熟練掌握一些常用方法(筆試大題一般常出現此類的靈活運用)
字符串轉數組 .toCharArray()
字符串中取指定位置 .charAt()
字符串與btye數組轉換 .getBytes()
計算字符串的長度 .length()
注意:數組中的length不帶()是屬性不是方法
查找指定字符串是否存在 .indexof()
去空格 .trim()
字符截取 .substring()
拆分字符串 .split()
小寫轉大寫 .toUpperCase()
大寫轉小寫 .toLowerCase()
常用的還有 .toString() .equals()
5.了解一些反射機制,垃圾回收機制(例如框架配置文件只讀取類名就可以獲取對應類中的方法即利用了反射)
反射機制:
框架配置文件只讀取類名就可以獲取對應類中的方法即利用了反射。
垃圾回收機制:
java程序員不需要關心,內存對象釋放問題;
由jvm來負責釋放內存,如果一個對象沒有任何引用指向他;
這個對象被視為垃圾,jvm會在空閑時,釋放這些空間;
而程序員不能控制,只能建議
System.gc()Runtime.getRuntime().gc()
6.了解線程的生命周期和其中常用方法(可以結合線程生命周期圖記憶)
線程完整的生命周期有:
新建(New)、就緒(Runable)、運行(Running)、阻塞(Blocked)和死亡(Dead)。
new時為新建狀態,
調用start()方法進入就緒狀態,
當cpu分配了時間片進入運行狀態,
時間片用完回到就緒狀態,
直到運行結束進入銷毀狀態,
其中在運行狀態遇到sleep()方法或等待io操作進入阻塞狀態,
阻塞狀態結束進入就緒狀態,再有cpu分配時間片執行,
線程運行時如果代碼被加了鎖,當前線程沒有獲得鎖,
當前對象進入鎖池,當鎖被釋放,線程獲得了到鎖回到就緒狀態,
當有鎖的線程調用wait()方法,當前線程進入等待池,釋放鎖,
直到有其他線程調用notify()或notifyAll()方法時等待的線程被喚醒,進入鎖池。
有幾種方式實現多線程
實現Runnable接口,實現run()方法
繼承Thread類,重寫run()方法
怎么解決同步問題
加鎖,synchronized,鎖方法,鎖代碼塊
7.熟記八大基本數據類型及其字節長度了解它們的包裝類
原始數據類型 大 小 包 裝 類
boolean(布爾型) 1 Boolean
byte(字節型) 8 Byte
char(字符型) 16 Character
short(短整型) 16 Short
int(整型) 32 Integer
long(長整型) 64 Long
float(浮點型) 32 Float
double(雙精度浮點型) 64 Double
8.了解值傳遞和引用傳遞的區別
對于基本數據類型,傳遞的是數據的拷貝;對于引用數據類型,傳遞的是引用的拷貝。
9.了解static、final、finally、finalize等修飾詞的意義
static:
靜態的
所有對象共享
屬于類的
能修飾 屬性,方法,內部類,靜態代碼塊
final: 不可改變
類 這個類不能被繼承
屬性 創建完對象以后不能被修改
變量 初始化以后不能被修改
方法 方法不能被重寫
finally:是異常處理語句結構的一部分,表示總是執行。
<pre spellcheck="false" style="margin: 5px 0px; padding: 5px 10px; border-radius: 3px; background: rgb(240, 240, 240); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; box-sizing: border-box; border-width: 0px; border-style: initial; border-color: initial; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; white-space: pre-wrap; color: rgb(34, 34, 34);"> try{
}catch(Exceptione){
}finally{
colse();
}</pre>
finalize:是Object類的一個方法,在垃圾收集器執行的時候會調用被回收對象的此方法,
供垃圾收集時的其他資源回收,例如關閉文件等。
<pre spellcheck="false" style="margin: 5px 0px; padding: 5px 10px; border-radius: 3px; background: rgb(240, 240, 240); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; box-sizing: border-box; border-width: 0px; border-style: initial; border-color: initial; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; white-space: pre-wrap; color: rgb(34, 34, 34);"> publicclass Test{
publicstatic void main(String[] args){
Testt = new Test();
...
System.gc();
}
} </pre>
10.了解io流的分類(字節流,字符流,緩沖流,橋梁等)并會簡單的讀寫文件
IO流的分類
方向
輸入流 輸出流
類型
字節流 字符流 對象流
字節流:
ByteArrayIn(Out)putStream 從內存數組中讀取數據字節
FileIn(Out)putStream 從本地文件中讀取數據字節
StringBufferIn(Out)putStream 從字符串中讀取數據字節
所有讀操作都繼承一個公共超類java.io.InputStream類。
所有寫操作都繼承一個公共超類java.io.OutputStream類。
字符流:
CharArrayReader(Writer) 從字符數組中讀取數據
FileReader(Writer) 從本地文件中讀取數據
StringReader(Writer) 從字符串中讀取數數據
所有讀操作都繼承一個公共超類java.io.Reader類。
所有寫操作都繼承一個公共超類java.io.Writer類。
對象流:
ObjectIn(Out)putStream
11.熟練掌握list set map等三類集合以及各實現類異同
List Set Map的區別:
List 有放入順序,可以重復
Set 沒有放入順序,元素不可以重復
Map 鍵值對形式存在
ArrayList LinkedList Vector的區別:
ArrayList,Vector底層都是數組
LinkedList底層是雙向鏈表
ArrayList線程不安全
Vector線程安全
HashMap和Hashtable的區別:
HashMap線程不安全,允許有一個key為null,value可以為空
Hashtable線程安全,key和value都不允許為null
12.了解網絡編程相關內容
網絡編程就是在兩個或兩個以上的設備(例如計算機)之間傳輸數據。程序員所作的事情就是把 數據發送到指定的位置,或者接收到指定的數據,這個就是狹義的網絡編程范疇。在發送和接收數據時,大部分的程序設計語言都設計了專門的API實現這些功能,程序員只需要調用即可。
13.了解異常相關的知識和一些常見的異常名稱,異常分類以及解決方法
異常和錯誤的區別
Exception 程序執行過程中程序員無法控制出現的問題
Error 人可以解決,程序員不關心
Exception和RuntimeException的區別
Exception 強制要求寫程序時處理 檢測異常/非運行時異常
RuntimeException 只有在運行時才會產生異常,不要求強制處理 運行時異常非檢測異常
處理異常有幾種方式
捕獲異常:
<pre spellcheck="false" style="margin: 5px 0px; padding: 5px 10px; border-radius: 3px; background: rgb(240, 240, 240); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; box-sizing: border-box; border-width: 0px; border-style: initial; border-color: initial; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; white-space: pre-wrap; color: rgb(34, 34, 34);"> try{
}catch(Exceptione){
}</pre>
拋出異常:
在代碼的方法體外用throws進行拋出聲明。
在代碼塊用throw手動拋出一個異常對象。
如果拋出的異常對象是非運行時異常,此方法的調用者必須顯示地用try..catch塊進行捕獲或者繼續向上層拋出異常。
如果拋出的異常對象是運行時異常,此方法的調用者可以選擇地進行異常捕獲處理。
(如果最終將異常拋給main方法,則相當于交給jvm自動處理,此時jvm會簡單地打印異常信息)
14.簡略了解三種類型的statement以及jdbc連接數據庫代碼和數據庫連接池的概念,優勢以及一些參數的意義
Statement 接口提供了三種執行 SQL 語句的方法:executeQuery、executeUpdate 、execute。
方法 executeQuery 用于產生單個結果集的語句,例如 SELECT 語句。
方法 executeUpdate 用于執行 INSERT、UPDATE 或 DELETE 語句以及 SQLDDL(數據定義語言)語句。
方法 execute用于執行返回多個結果集、多個更新計數或二者組合的語句。
JDBC連接數據庫:
1、加載JDBC驅動程序;
<pre spellcheck="false" style="margin: 5px 0px; padding: 5px 10px; border-radius: 3px; background: rgb(240, 240, 240); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; box-sizing: border-box; border-width: 0px; border-style: initial; border-color: initial; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; white-space: pre-wrap; color: rgb(34, 34, 34);"> try{
//加載MySql的驅動類
Class.forName("com.mysql.jdbc.Driver");
}catch(ClassNotFoundExceptione){
System.out.println("找不到驅動程序類 ,加載驅動失敗!");
e.printStackTrace();
} </pre>
2、創建數據庫的連接;
<pre spellcheck="false" style="margin: 5px 0px; padding: 5px 10px; border-radius: 3px; background: rgb(240, 240, 240); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; box-sizing: border-box; border-width: 0px; border-style: initial; border-color: initial; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; white-space: pre-wrap; color: rgb(34, 34, 34);"> Stringurl ="jdbc:mysql://jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&setCharacterEncoding=utf8";
String username ="root" ;
String password ="root" ;
try{
Connection con =DriverManager.getConnection(url , username , password );
}catch(SQLException e){
System.out.println("數據庫連接失敗!");
e.printStackTrace();
} </pre>
3、創建一個Statement;
<pre spellcheck="false" style="margin: 5px 0px; padding: 5px 10px; border-radius: 3px; background: rgb(240, 240, 240); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; box-sizing: border-box; border-width: 0px; border-style: initial; border-color: initial; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; white-space: pre-wrap; color: rgb(34, 34, 34);"> Statementstmt = conn.createStatement();
//PreparedStatementps = conn.prepareStatement("select * from t_user");</pre>
4、執行SQL語句;
<pre spellcheck="false" style="margin: 5px 0px; padding: 5px 10px; border-radius: 3px; background: rgb(240, 240, 240); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; box-sizing: border-box; border-width: 0px; border-style: initial; border-color: initial; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; white-space: pre-wrap; color: rgb(34, 34, 34);"> ResultSetrs = stmt.executeQuery("select * from t_user");
//ResultSetrs = ps.executeQuery();</pre>
5、處理結果;
<pre spellcheck="false" style="margin: 5px 0px; padding: 5px 10px; border-radius: 3px; background: rgb(240, 240, 240); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; box-sizing: border-box; border-width: 0px; border-style: initial; border-color: initial; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; white-space: pre-wrap; color: rgb(34, 34, 34);"> while(rs.next()) {
intid = rs.getInt("id");
Stringusername = rs.getString("username");
Stringpassword = rs.getString("password");
System.out.println(id+ "\t" + username + "\t" + password);
}</pre>
6、關閉JDBC對象。
<pre spellcheck="false" style="margin: 5px 0px; padding: 5px 10px; border-radius: 3px; background: rgb(240, 240, 240); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; box-sizing: border-box; border-width: 0px; border-style: initial; border-color: initial; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; white-space: pre-wrap; color: rgb(34, 34, 34);"> if(rs != null) {
rs.close();
}
if(ps != null) {
ps.close();
}
if(stmt != null) {
stmt.close();
}
if(conn != null) {
conn.close();
}</pre>
二、javeWeb階段
1.了解html以及css樣式的常用屬性
文本對齊屬性(text-align)
文本修飾屬性(text-decoration) 多用于a鏈接 加上橫線
文本縮進屬性(text-indent)
行高屬性(line-height)
顏色屬性(color)
字體(font)
超鏈接 <a href="想鏈接網址">鏈接地的名稱</a>
貼圖 <img src="圖形的網址">
display 默認
CSS符號屬性:
list-style-type:none; /不編號/
CSS背景樣式:
background-color:#F5E2EC; /背景顏色/
指定背景位置
background-position : top; /向上對齊/
常用的3種樣式:
1)最常用的,外部文件導入格式標簽:
<pre spellcheck="false" style="margin: 5px 0px; padding: 5px 10px; border-radius: 3px; background: rgb(240, 240, 240); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; box-sizing: border-box; border-width: 0px; border-style: initial; border-color: initial; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; white-space: pre-wrap; color: rgb(34, 34, 34);"> <linkhref="css/style.css" rel="stylesheet"type="text/css"></pre>
2)在Html頭部用<style></style>包起來,直接引用:
<pre spellcheck="false" style="margin: 5px 0px; padding: 5px 10px; border-radius: 3px; background: rgb(240, 240, 240); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; box-sizing: border-box; border-width: 0px; border-style: initial; border-color: initial; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; white-space: pre-wrap; color: rgb(34, 34, 34);"> <styletype="text/css">
*{
padding:0;margin: 0
}
</style></pre>
3)javascript- 加載外部.js獨立文件:
<pre spellcheck="false" style="margin: 5px 0px; padding: 5px 10px; border-radius: 3px; background: rgb(240, 240, 240); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; box-sizing: border-box; border-width: 0px; border-style: initial; border-color: initial; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; white-space: pre-wrap; color: rgb(34, 34, 34);"> <scripttype="text/javascript" src="/script.js"></script></pre>
2.熟練jsp九大內置對象四大作用域以及jstl和el表達式
out(JspWriter) 字符輸出流
request 請求對象、請求域(GET/POST)
response 響應對象、重定向
session 會話作用域
application 全局作用域
config 當前Servlet組件或者JSP頁面的初始化參數引用
pageContext(PageContext) 當前JSP頁面的作用域
page(this->HttpJspPage) 引用自己頁面(是個Object)
exception 它是頁面中出現異
page: 當前頁面有效,跳轉就結束。
request: 可以跨越forward前后兩個頁面,刷新就結束。
session: 存在當前瀏覽器,關閉瀏覽器結束。
application: 從服務器啟動開始,到停止后結束。
JSTL(JSP Standard Tag Library ,JSP標準標簽庫)是一個不斷完善的開放源代碼的JSP標簽庫。
Java 中jsp中的EL用法如下:
1、語法結構
<pre spellcheck="false" style="margin: 5px 0px; padding: 5px 10px; border-radius: 3px; background: rgb(240, 240, 240); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; box-sizing: border-box; border-width: 0px; border-style: initial; border-color: initial; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; white-space: pre-wrap; color: rgb(34, 34, 34);"> ${expression}</pre>
2、[ ]與.運算符
EL 提供“.“和“[ ]“兩種運算符來存取數據。
當要存取的屬性名稱中包含一些特殊字符,如 . 或 - 等并非字母或數字的符號,就一定要使用“[ ]“。例如:
<pre spellcheck="false" style="margin: 5px 0px; padding: 5px 10px; border-radius: 3px; background: rgb(240, 240, 240); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; box-sizing: border-box; border-width: 0px; border-style: initial; border-color: initial; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; white-space: pre-wrap; color: rgb(34, 34, 34);"> {user["My-Name"]}</pre>
如果要動態取值時,就可以用“[ ]“來做,而“.“無法做到動態取值。例如:
<pre spellcheck="false" style="margin: 5px 0px; padding: 5px 10px; border-radius: 3px; background: rgb(240, 240, 240); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; box-sizing: border-box; border-width: 0px; border-style: initial; border-color: initial; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; white-space: pre-wrap; color: rgb(34, 34, 34);"> ${sessionScope.user[data]}中data 是一個變量</pre>
3、變量
EL存取變量數據的方法很簡單,例如:${username}。它的意思是取出某一范圍中名稱為username的變量。
因為我們并沒有指定哪一個范圍的username,所以它會依序從Page、Request、Session、Application范圍查找。
假如途中找到username,就直接回傳,不再繼續找下去,但是假如全部的范圍都沒有找到時,就回傳null。
4.了解include指令和動作的區別,session與cookie的異同,隔行變色的實現方法
【include指令和動作的區別】
include指令合并靜態文檔或Jsp頁面中的內容,可以用于包括動態生成的輸出結果,因此可以包含一個Servlet 。
include指令在編譯期合并為一個文檔 。 include動作在請求時進行包括處理。
共享局部變量
include指令各文件中的聲明的腳本變量在所有組成的頁面中有效 。
include動作在一個文件中聲明的腳本變量不能用于其他頁面,除非將變量放置在request,session,application作用域中。
修改的生效
include指令被包含文件被修改,不會立即生效,除非修改主頁面或刪除主頁面的類。
include動作修改了被包含的文件立即生效。
變量的作用域
include指令中的要注意變量命名沖突情況 。
include動作不會出現變量命名沖突問題,因為他們實際上是局部變量。
【session與cookie的異同】
cookie數據存放在客戶的瀏覽器上,session數據放在服務器上。
cookie不是很安全,別人可以分析存放在本地的cookie并進行cookie欺騙考慮到安全應當使用session。
session會在一定時間內保存在服務器上。當訪問增多,會比較占用你服務器的性能考慮到減輕服務器cookie當使用cookie。
單個cookie保存的數據不能超過4K,很多瀏覽器都限制一個站點最多保存20個cookie。
所以建議,將登陸信息等重要信息存放為session其他信息如果需要保留,可以放在cookie中。
5.了解xml文件的語法規則與書寫規范
XML元素都須有關閉標簽,
XML 標簽對大小寫敏感,
XML 必須正確地嵌套,
XML 文檔必須有根元素,
XML 中的注釋,
XML 的屬性值須加引號,
在 XML 中,空格會被保留,
XML 以 LF 存儲換行。
6.熟悉servlet生命周期,jsp頁面的執行過程以及監聽器過濾器的作用場合和用法
Servlet的生命周期由Servlet容器控制,該容器創建Servlet的實例。Servlet的生命周期就是指Servlet實例在創建之后響應客戶請求直到至銷毀的全過程。Servlet實例的創建取決于Servlet的首次調用。Servlet接口定義了Servlet生命周期的3個方法。
init():創建Servlet的實例后對其進行初始化。
service():響應客戶端發出的請求。
destroy():如果不需要處理的請求,則釋放Servlet實例。
注意:Servlet關閉時才銷毀。
JSP頁面的執行過程:
- 用戶請求JSP頁面(HTTP請求),
2. web server中的servlet容器發現URL中有JSP后綴, 就調用JSP容器來處理,
- 如果此頁面是第一次被請求, JSP容器要定位JSP頁面文件并解釋它,
解釋的過程包括: 將JSP源文件處理成servlet代碼(java), 以及編譯java文件生成servlet的call文件.
說明: JSP解釋器生成的servlet類是實現了java.servlet.jsp.HttpJspPate接口的類(由JSP容器提供)的一個子類, 這個servlet類叫做頁面實現類(JSP頁面實例);
4. JSP容器運行頁JSP頁面實例, 此時servlet(即JSP頁面實例)就會出來HTTP請求, 生成對于的HTTP響應并傳回給客戶端.
如果此頁面不是第一次被請求, 則跳過3, 直接跳到4.
Servlet監聽器是給Web應用增加事件處理機制,以便更好地監視和控制Web應用的狀態變化,從而在后臺調用相應處理程序。
Web.xml 配置:監聽器
<pre spellcheck="false" style="margin: 5px 0px; padding: 5px 10px; border-radius: 3px; background: rgb(240, 240, 240); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; box-sizing: border-box; border-width: 0px; border-style: initial; border-color: initial; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; white-space: pre-wrap; color: rgb(34, 34, 34);"> <listener>
<listener-class>pageage.listenerclass</listener-class>
</listener></pre>
解決亂碼問題:
<pre spellcheck="false" style="margin: 5px 0px; padding: 5px 10px; border-radius: 3px; background: rgb(240, 240, 240); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; box-sizing: border-box; border-width: 0px; border-style: initial; border-color: initial; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; white-space: pre-wrap; color: rgb(34, 34, 34);"> public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException {
request.setCharacterEncoding("utf-8");
chain.doFilter(request, response);
response.setCharacterEncoding("utf-8");
}</pre>
Web.xml 配置:過濾器
<pre spellcheck="false" style="margin: 5px 0px; padding: 5px 10px; border-radius: 3px; background: rgb(240, 240, 240); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; box-sizing: border-box; border-width: 0px; border-style: initial; border-color: initial; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; cursor: text; counter-reset: list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; white-space: pre-wrap; color: rgb(34, 34, 34);"> <filter>
<filter-name>filter</filter-name>
<filter-class>itany.filter.com.TestFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping></pre>
7.了解ajax區分何時用局部刷新何時用iframe刷新并會寫ajax的js代碼(原始ajax和jquery版的)
iframe是一個內聯框架,你可以理解為在原有的HTML內多出的一個獨立的框架,從刷新這個框架能做到類似“局部刷新”的效果。
而AJAX是一種局部刷新的技術,它本身而言可以針對這個頁面所有的元素,而不像iframe那樣,只能局部刷新其“圈起來”的部分。
從性能上來說,如果一個頁面比較大,對局部刷新比較多的情況下,比如有太多地方都可能需要獨立刷新,如果你用N個iframe的話,對系統的性能消耗就比較明顯了,直接的結果就是頁面加載起來會慢。
8.了解jquery理解其核心是取得頁面元素對象及熟悉一些常用的方法明白其是對js的一種封裝
jquery 中動態綁定事件:
bind、live、delegate、on,對應的解除監聽的函數分別是unbind、die、undelegate、off。
jquery中迭代的方法:each。
jsp和servlet的區別:
jsp適合前端顯示數據,servlet適合接受數據、控制數據跳轉流程。
三、數據庫
Oracle中的觸發器的類型可劃分為4種:
數據操縱語言(DML)觸發器
替代(INSTEAD OF)觸發器
數據定義語言(DDL)觸發器
數據庫事件觸發器
Oracle 關聯查詢的區別:
內連接:即最常見的等值連接。
左連接:是在等值連接的基礎上加上主表中的未匹配數據。
右連接:是在等值連接的基礎上加上被連接表的不匹配數據。
全外連接:是在等值連接的基礎上將左表和右表的未匹配數據都加上,全外連接的等價寫法,對同一表先做左連接,然后右連接。
數據庫的存儲過程:
其實存儲過程和函數是相似的,或者干脆把存儲過程理解為另一種經過優化的函數。
它的優點在于,存儲過程在被編譯后會被直接保存在數據庫中,成為數據庫的一部分,
以后就可以反復調用,運行速度快,效率高。。。
索引 :
索引是對數據庫表中一列或多列的值進行排序的一種結構。
優點:
大大加快數據的檢索速度;
創建唯一性索引,保證數據庫表中每一行數據的唯一性;
加速表和表之間的連接;
在使用分組和排序子句進行數據檢索時,可以顯著減少查詢中分組和排序的時間。
缺點:
索引需要占物理空間。
當對表中的數據進行增加、刪除和修改的時候,索引也要動態的維護,降低了數據的維護速度。
oracle中truncate和delete的區別:
1.truncate和 delete只刪除數據不刪除表的結構(定義)
2.delete語句是dml,這個操作會放到rollback segement中,事務提交之后才生效;
如果有相應的trigger,執行的時候將被觸發truncate,drop是ddl, 操作立即生效,原數據不放到rollback segment中,不能回滾.操作不觸發trigger。
3.速度,一般來說: drop> truncate> delete。
4.安全性:小心使用drop 和truncate,尤其沒有備份的時候.否則哭都來不及。
5.使用上,想刪除部分數據行用delete,注意帶上where子句. 回滾段要足夠大. 想刪除表,當然用drop
想保留表而將所有數據刪除. 如果和事務無關,用truncate即可. 如果和事務有關,或者想觸發trigger,還是用delete
數據庫的優化:
1.查詢語句優化:
避免過多的表關聯,注意where 中的字段順序,先過濾有索引的,能盡量縮小數據范圍的等。
2.索引優化:
合理分析并設置、調整索引。
3.表結構優化:
如果數據量過大,縱向或者橫向拆分表。縱向拆,將前n個字段放在一個表,后面m個放另一個表。橫向:滿足一定條件的數據放一個表,比如公司員工特別多,男雇員放一個,女雇員放一個表,人妖放一個表。
4.存儲方式優化:
通過不同的存儲空間或者表分區,將數據存放在不同的存儲區域,達到充分利用IO的目的
熟悉一些mysql的創庫創表增刪改查語句,oracle的權限賦予及各種函數的使用;
創庫: create database 項目名 default charset utf8( 格式 ) collate utf8_general_ci;
熟悉oracle的圖形化工具,熟練各種查詢語句以及視圖,序列,觸發器,索引的概念和作用
熟練運用mysql的limit和oracle的rownum進行分頁。
四、框架部份
框架部分具體細化問題可能問的比較少,一般問的都是從大方面出發比如各個框架的優缺點,異同等等。
Hibnernate (冬眠)
持久層框架:
Hibernate是一個基于JDBC的主流持久層框架,對JDBC訪問數據庫的代碼做了封裝,簡化DAO層的編碼工作,對象關系映射的靈活性出色,它支持各種關系數據庫,從一對一到多對多的各種復雜關系。
hibernate核心API
Configuration 用于解析hibernate.cfg.xml和Xxx.hbm.xml,并創建SessionFactory對象。
SessionFactory 用于創建Session,很消耗資源,線程安全,單例。
Session 會話,持久化管理器,線程不安全,每次提供新的Session對象。
Transaction 事務管理器。
Hibernate和Mybatis同為持久層框架 經常會拿來比較異同?
Mybatis優勢:
MyBatis可以進行更為細致的SQL優化,可以減少查詢字段。
MyBatis容易掌握,而Hibernate門檻較高。
Hibernate優勢:
Hibernate對DAO層開發更簡單,
Hibernate 對數據庫移植性要好。
Hibernate有更好的二級緩存機制,可以使用第三方緩存。
Spring的核心是ioc和aop各自的含義和作用分別是什么?
Spring就是一個輕量級的控制反轉(IoC)和面向切面(AOP)的容器框架。
IOC:控制反轉,是一種設計模式。一層含義是控制權的轉移:由傳統的在程序中控制依賴轉移到由容器來控制;第二層是依賴注入:將相互依賴的對象分離,在spring配置文件中描述他們的依賴關系。他們的依賴關系只在使用的時候才建立。簡單來說就是不需要NEW一個對象了。
AOP:面向切面,是一種編程思想,OOP的延續。將系統中非核心的業務提取出來,進行單獨處理。比如事務、日志和安全等。這個簡單來說就是可以在一段程序之前或者之后做一些事。
Spring 的AOP和IOC都是為了解決系統代碼耦合度過高的問題。使代碼重用度高、易于維護。不過AOP和IOC并不是spring中特有的,只是spring把他們應用的更靈活方便。
mvc模型的三層分別是指項目中的哪些類使用mvc的原因是什么?
三層架構是三層架構:三層架構是數據訪問層,業務邏輯層,和表示層。
三層架構是為了體現高內聚和低耦合,但是還未完全體現這種思想。
MVC是由Model(模型)放置業務實體,表示操作數據;View(視圖)放置UI模板文件,負責展示輸出結果;Controller(控制器)放置Controller類,處理URL請求 組成的。通常是和三成架構、工廠等一起使用,可以將高內聚和低耦合的概念體現得淋漓精致。
五、設計模式了解的越多越好目前我們接觸過的可能不過就是單例模式,工廠模式以及一點代理模式 這三個模式要有一定的了解
單例模式:
程序運行期間,
這個類有且只有一個實例。
簡單工廠模式
創建對象,降低調用者和實現者的耦合度。
靜態代理模式
不改變現有代碼基礎上增加新的功能。
適配器模式
底層操作的數據時相同的數據,將某一一種類型轉成另一種類型。
六、總結
面試并不可怕如果大家面試多了就會發現其實很簡單,問來問去不過就那么些問題,面試你的人或許也只有一兩年開發經驗并沒有我們想象中那么厲害,需要注意的:
首先是面試盡量早到雖然有些公司不在意這些但是起碼不要遲到
第二就是要注意禮貌給面試官留下一個好印象錄用你的機會總是會比別人大一些的
第三面試過程中要自信不要支支吾吾這樣就算答出來了印象也不會好,聽完問題如果沒理解就讓面試官再具體問一下,確認理解了問題在腦子里組織好答案一氣呵成即可,如果沒學過的可以直接說畢竟我們都是剛入門的菜鳥大家都能理解的
第四面試結束之后回想起面試過程中答不出的問題 一定要及時找出答案以面對以后的面試 我當時用手機查出答案都會保存書簽每天睡覺之前會瀏覽一遍
第五找到工作了不代表萬事大吉 每個公司都有自己的框架和開發側重點 才入門的時候總是最痛苦的 也許開發工具,數據庫,框架,技術等等你都一無所知就開始有了任務,不要灰心菜鳥都是這樣熬過來的,進公司之后百度就是你最好的老師,同事都在百度之后畢竟每個人都有自己的活,有些問題一時半會也不一定能解決好。要學會利用百度搜索有用信息,也要多問同事也許別人的一句話就能讓你少走許多彎路。
最后祝大家都能找到一份滿意的工作開啟自己的JAVA之路。
更多資源去查看公眾號里的 ****資源匯總