天天看點

知識點小積累

1、{ }大括号标注的都是對象,()小括号标注的都是數組

2、int arrar[][]=new int[2][3]:建立了一個有兩行三列的數組,int i<arra.length()得到的結果是行數,int j<array[i].lengrh()得到的結果是列數

3、通過foreach循環周遊二維數組

     int array[][]=new int[2][3];

     //首先得到一維數組,就是說多少行

     for(int arr[]:array){

       //接着得到每行裡面的多少咧

        for(int x:arr){

     }

   }

4、注意可以在每個類的main函數當中可以調用本類,通過建立構造函數其實也可以執行某些功能性函數

5、枚舉的學習:enum seasons{

       spring,summer,autumn,winner

}

6、架構配置的時候:頭檔案有一堆<beans xmlns="http://www.spring....."></beans> ,如果導入的時候報出紅色錯誤的話

           方法:window--preperences--搜xml得到xml catalog--進入選擇相應的加入即可

7、開發javaweb項目需要合适的(jdk,ssm價包,tomcat容器),因為所有的web項目最終都是在tomcat容器中運作的,是以要在server中為項目工程配置jdk,具體方法如下:(點選server--add)

知識點小積累

   但是普通的java工程在build path中添加jdk系統包就行,因為這些項目是在eclipse的workspace當中執行的。

8、javaweb項目運作之後的通路路徑:http://localhost:8080/項目工程名字/映射的url   (http://localhost:8080/springmvcMyFirst/queryItems.action)

9、spring配置檔案中:ref是用在,當xml中先前已經配置了<bean>标簽了,在使用它的時候要用ref ,ref是存的是對象的引用

                                                   在spring配置檔案裡面,value填的參數,一般是用在配置檔案、數字,字元串之類的,而不能放對象.

10、ssm的springmvc在映射的時候:首先,由view發送請求,如果controller接收到的值是包裝類,那麼前端傳的值一定要是包裝類的屬性值,即要求所傳值的根名稱要與屬性值一緻

                                                      其次,前端view在接收controller發過來的值的時候,使用jstl的方式,接收到的值的名字要與controller中放到model中值的名字一緻,否則接受失敗。

如下所示:其中${itemlist}中的itemlist與contoller對應方法傳回的值定義的名字一緻,itemlist[${status.index }]中的itemlist與包裝類vo中定義的屬性值一緻

<c:forEach items="${itemlist}" var="itemlist" varStatus="status">

<tr>  

    <td><input name="itemlist[${status.index }].id" value="${itemlist.id }"/></td> 

<td><input name="itemlist[${status.index }].name" value="${itemlist.name }"/></td>

<td><input name="itemlist[${status.index }].price" value="${itemlist.price }"/></td>

<td><input name="itemlist[${status.index }].createtime" value="<fmt:formatDate value="${itemlist.createtime}" pattern="yyyy-MM-dd HH:mm:ss"/>"/></td>

<td><input name="itemlist[${status.index }].detail" value="${itemlist.detail }"/></td>

</tr>

</c:forEach>

11、關于絕對路徑的一點分析:${pageContext.request.contextPath}是從這個請求路徑(URL)上截取你的項目應用名的,比如你的項目名是hello,截取的結果應該就是/hello,/代表http//:localhost:8080。

12、通過url通路web項目:

              首先找到web.xml(這個檔案将所有的controller—.action映射到webroot根目錄下面),

              web.xml中定義welcome-list标簽,設定出預設通路頁面,從根路徑開始:

知識點小積累

13、從其他地方拷貝進來一個javaweb工程: 首先build path新的jdk,其次導入相應的資源檔案jar包,其次選擇适合的tomcat版本,最後在項目的properties中設定project facet

14、java scaner的使用方法:next(讀入一個 字元串)+nextline(讀入一行)+nextint(讀入一個數值)