SSH整合應(yīng)用+Jquary+Flexigrid實現(xiàn)表格數(shù)據(jù)顯示_第1頁
SSH整合應(yīng)用+Jquary+Flexigrid實現(xiàn)表格數(shù)據(jù)顯示_第2頁
SSH整合應(yīng)用+Jquary+Flexigrid實現(xiàn)表格數(shù)據(jù)顯示_第3頁
SSH整合應(yīng)用+Jquary+Flexigrid實現(xiàn)表格數(shù)據(jù)顯示_第4頁
SSH整合應(yīng)用+Jquary+Flexigrid實現(xiàn)表格數(shù)據(jù)顯示_第5頁
已閱讀5頁,還剩2頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、SSH整合:學(xué)習(xí)過程中的一個實例,麻雀雖小五臟俱全!應(yīng)用到了 SSH整合及Jquery框架flexigrid插 件,實現(xiàn)列表數(shù)據(jù)顯示。以下是主要整合配置和JAVA源碼(帶注釋)一、導(dǎo)入所有需要的Jar包二、Web.xml 配置strutsfilterorg.apache.struts2.dispatcher.ng.filter.StrutsPrepa reAndExecuteFilterstrutsfilter/*contextConfigLocationclasspath:applicationContext-*.xmlorg.springframework.web.context.Cont

2、extLoaderListenerindex.jsp三、Struts2配置Struts.xml package namespace=/user name=demo-user extends= json-default /WEB-INF/demo/user_list.jsp 四、src 下三 個 XML : ( applicationContext-database.xml; applicationContext-service.xml;applicationContext-dao.xml)分別為配置的數(shù)據(jù)源、服務(wù)層、DAO層其內(nèi)容如下:applicationContext-database.x

3、ml org.hibernate.dialect.MySQLDialect 路徑 +/User.hbm.xml applicationContext-service.xmlapplicationContext-dao.xmlbean id=userDao class = 引入dao層實現(xiàn)類 五、Action 類package 火火火火火;導(dǎo)包火火火火火火火火火火;public class UserAction extends BaseAction (private static final long serialVersionUID = 1L;private Integer page; / 當(dāng)

4、前頁private Integer totle; /共幾頁private Integer rp;/ 每頁顯示條目private List users;/注入業(yè)務(wù)private UserService userService;private HttpServletResponse response;public void getUserList() throws Exception (try (System.out.println(xxxxxxxxxxxxxxxxxxx);users = userService.findAll();response = ServletActionContext.

5、getResponse();response.setContentType(application/json;charset=GBK); String jsonStr = getJsonStr(users);response.getWriter().write(jsonStr); catch (RuntimeException e) ( e.printStackTrace();throw new Exception(e);public String getJsonStr(List list) (Map map = new HashMap();map.put( page , page); / 當(dāng)

6、前頁數(shù)map.put( total , list.size(); / 總記錄數(shù)List rows = new ArrayList();for (Iterator iterator = list.iterator(); iterator.hasNext();) (User user = (User) iterator.next();Map cellMap = new HashMap();JSONObject json = new JSONObject(); json.put(id, user.getId();json.put(name, user.getName();cellMap.put(id

7、, user.getId(); cellMap.put(cell, json);rows.add(cellMap); map.put(rows, rows); JSONObject object = JSONObject. fromObject (map); return object.toString();/*屬性訪問方法*/*六、JSP 頁面使用 JQuery+flexigrid FlexiGrid Demo var a=document.body.clientHeight-143;var b=document.body.clientWidth-3;var clientScreen = window.screen.width;var one,two;one = b*0.03;two = b*0.17;$(#flex1).flexigrid( (url: ./user/getUsers.action, dataType: json, colModel :(display: ID, name : id, width : one, sortable : false, align: left,(display:姓名, name : name, width : two, sortable : true, align: left,sortname: id,

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論