Spring MVC從後臺讀取資料庫並顯示在前臺頁面的實現
1. 寫jsp頁面 people.jsp
設計顯示格式以及內容顯示
2. 設計顯示內容的範圍
寫entity實體類 PeopleFormMap.java
寫傳入的引數主要包括:要引用的資料庫名,以及主鍵欄位h_eventid
3.寫service層
PeopleService 繼承底層的 BaseService
4.寫service實現類 PeopleServiceImpl
@peopleservice
5.寫controller層 PeopleController Controller實現 介面和service實現類的資料互動
@RequestMapping(“/people”)
public class PeopleController extends BaseController{
private PeopleService peopleservice;
@ResponseBody
@RequestMapping("peoplelist")
public String peoplelist(String txtSelect ) throws Exception{
return "success";}
}
6.寫js頁面
function initPeopleList(){
var url= rootPath + '/people/findByPage.shtml';
寫想要顯示欄位內容
封裝data{
}
}
7.mapping
寫sql查詢語句
<mapper namespace="RiskForcastMapper">
<select id="" resultType="java.util.HashMap">
select * from .
</select>