當前位置:編程學習大全網 - 源碼下載 - spring與dwr集成問題

spring與dwr集成問題

dwr+spring集成

DWR(Direct Web Remoting)是壹個用於改善web頁面與Java類交互的遠程服務器端Ajax開源框架,可以幫助開發人員開發包含AJAX技術的網站.它可以允許在瀏覽器裏的代碼使用運行在WEB服務器上的JAVA函數,就像它就在瀏覽器裏壹樣。

以下模擬壹個簡單的dwr入門案例,重點理解dwr是如何跟java後臺服務器打交道的

模擬效果如下

該功能說明了dwr是怎麽跟後臺服務器打交道的

模擬從服務器加載下拉列表數據

新建業務邏輯類

DeptServices類

package services;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import entity.Dept;

@SuppressWarnings("unchecked")

public class DeptServices {

public List findDept() {

throw new RuntimeException("查找失敗!");

}

public void deleteDept(Long id) {

System.out.println("Delete dept " + id);

}

public List getDeptsForPo() {

List depts = new ArrayList();

depts.add(new Dept(1l, "教質部"));

depts.add(new Dept(2l, "學術部"));

depts.add(new Dept(3l, "就業部"));

depts.add(new Dept(4l, "咨詢部"));

return depts;

}

public void saveDept(List<Dept> depts) {

// System.out.println(dept.getId() + ":" + dept.getName());

System.out.println(depts);

}

public List getDepts() {

List depts = new ArrayList();

Map map = new HashMap();

map.put("id", "01");

map.put("name", "教質部");

depts.add(map);

map = new HashMap();

map.put("id", "02");

map.put("name", "學術部");

depts.add(map);

map = new HashMap();

map.put("id", "03");

map.put("name", "就業部");

depts.add(map);

map = new HashMap();

map.put("id", "04");

map.put("name", "咨詢部");

depts.add(map);

try {

Thread.sleep(1000);

} catch (InterruptedException e) {

e.printStackTrace();

}

return depts;

}

}

  • 上一篇:萬網雲虛擬主機怎麽用,如何配置
  • 下一篇:盈利模式不清晰 APP的“泡沫”會吹破嗎
  • copyright 2024編程學習大全網