spring面試大全

2022-02-21 18:28:50 字數 552 閱讀 8900

四、spring如何建立乙個資料連線池 $$

$$五、在spring框架中如何更加高效的使用jdbc

使用spring框架提供的模板類jdbctemplete可以是jdbc更加高效

**如下:jdbctemplate template = new jdbctemplate(mydatasource);

dao類的例子:

public class studentdaojdbc implements studentdao

more..

} 配置檔案:

這個配置檔案就定義了乙個標識為 helloworld 的bean。在乙個配置文件中可以定義多個bean。

二、bean的初始化

有兩種方式初始化bean。

1、在配置文件中通過指定init-method 屬性來完成

在bean的類中實現乙個初始化bean屬性的方法,如init(),如:

public class helloworld

…… }

然後,在配置檔案中設定init-mothod屬性:

Spring註解大全

spring4之後加入的註解,原來在 controller中返回json需要 responsebody來配合,如果直接用 restcontroller替代 controller就不需要再配置 responsebody,預設返回json格式。crossorigin restcontroller pub...

Spring註解大全(二)

目錄 定義切點,切點表示式 execution 許可權訪問符 返回值型別 方法所屬的類名包路徑.方法名 形參型別 異常型別 aspect component public class afterthrowingaspect 前置增強,配合 pointcut一起使用 aspect component ...

Spring註解大全(三)

目錄 所有方法在呼叫前,先執行此 modelattribute方法.a.標註在有返回值的方法上 當modelattribute設定了value,方法返回的值會以這個value為key,以引數接受到的值作為這個key對應的value,組成k v鍵值對,存入到model中,如下面的方法執行之後,最終相當...