濮阳杆衣贸易有限公司

主頁 > 知識庫 > JSP實現(xiàn)客戶信息管理系統(tǒng)

JSP實現(xiàn)客戶信息管理系統(tǒng)

熱門標簽:自繪地圖標注數(shù)據(jù) 外呼系統(tǒng)使用方法 南通通訊外呼系統(tǒng)產(chǎn)品介紹 潤滑油銷售電銷機器人 給地圖標注得傭金 電銷機器人免培訓 如何看懂地圖標注點 電話機器人需要使用網(wǎng)絡(luò)嗎 海外圖書館地圖標注點

本文實例為大家分享了JSP實現(xiàn)客戶信息管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

項目示意圖大概這樣吧。我自己畫的

登錄界面代碼

index.jsp: 完全沒技術(shù)含量的,直接調(diào)用一個servlet控制的是否登錄

%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
html>
 head>

 title>客戶信息管理系統(tǒng)登錄/title>
 /head>

 body>

   h2>客戶信息管理系統(tǒng)登錄/h2>
   form action="LoginServlet" method="post">
   用戶名:input type="text" name="name"/>br/>
   密 碼:input type="text" name="pwd"/>br/>
   input type="submit" value="登錄"/>
   /form>
 /body>
/html>

控制登錄的 LoginServlet

public class LoginServlet extends HttpServlet {

 public void doGet(HttpServletRequest request, HttpServletResponse response)
   throws ServletException, IOException {
  doPost(request, response);
 }

 public void doPost(HttpServletRequest request, HttpServletResponse response)
   throws ServletException, IOException {
   String name = request.getParameter("name");
   String pwd = request.getParameter("pwd");
   //此時應(yīng)該要把賬號密碼封裝成JavaBean 訪問后臺數(shù)據(jù)庫驗證登錄,這里簡化了
   if(name!=null  name.startsWith("hncu")  pwd!=null pwd.length()>3){
    //登錄成功,訪問主頁
    request.getSession().setAttribute("name", name);
    request.getRequestDispatcher("/jsps/table.jsp").forward(request, response);
   }else{//登錄失敗,重修返回登錄界面
    response.sendRedirect(request.getContextPath()+"/index.jsp");
   }

 }

}

進來之后就到我們的主頁后點擊添加按鈕,開頭彈出一個窗口讓我們輸入添加的信息

這個技術(shù)原理

function add(){
 var url = path+"/jsps/input.jsp";
 var returnValue =window.showModalDialog(url, "","dialogHeight:400px;dialogWidth:300pxl;status:no");
  if(returnValue){
//    alert(returnValue.id);
   realAdd(returnValue);
  }
}

url:是彈出小窗口的路徑。后面是設(shè)置彈出窗口的參數(shù)。
返回值可以拖過這個語句提供

window.returnValue=obj;

下面是這個添加過程的示意圖

主頁代碼以及JS代碼

%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
html>
 head>
 link rel="stylesheet" type="text/css" href="c:url value='/css/table.css'/>" rel="external nofollow" >
 title>客戶信息管理系統(tǒng)/title>
 script type="text/javascript" src='c:url value="/js/table.js"/>'>/script>
  script type="text/javascript">
  var path = "c:url value='/'/>";
  /script>
 /head>

 body>
   h2>客戶信息管理系統(tǒng)/h2>
   input type="button" onclick="del();" value="刪除"/>
   input type="button" value="添加" onclick="add()" >

   table id="tb">
   tr>
    th>選擇input type="checkbox" id="parentChk" onclick="chk(this);">/th>
   th>姓名/th>th>年齡/th>th>地址/th>th class="iid">ID/th>
   /tr>
   /table>

 form name="f1" target="ifrm" action="c:url value='/DelServlet'/>" method="post">
  input id="ids" type="hidden" name="ids"/> 
  /form>
  iframe name="ifrm" style="display:none;">/iframe>
 /body>
/html>

table.js

 function add(){
  var url = path+"/jsps/input.jsp";
  //var vReturnValue = window.showModalDialog(url,"","dialogWidth:400px;dialogHeight:200px;status:no;");
  var returnValue =window.showModalDialog(url, "","dialogHeight:400px;dialogWidth:300pxl;status:no");
  if(returnValue){
//    alert(returnValue.id);
   realAdd(returnValue);
  }
}
// 把封裝過來的數(shù)據(jù)實際插入到表格
 function realAdd(obj){
  var tb = document.getElementById("tb");
  var oTr = tb.insertRow();
  var oCell = oTr.insertCell();
  oCell.innerHTML='input type="checkbox" name="chk" onclick="subchk(this);"/>';
  oCell = oTr.insertCell();
  oCell.innerHTML=obj.name;

  oCell = oTr.insertCell();
  oCell.innerHTML=obj.age;

  oCell = oTr.insertCell();
  oCell.innerHTML=obj.addr;

  oCell = oTr.insertCell();
  oCell.innerHTML=obj.id;
  oCell.className="iid";
}

//全先復(fù)選框,點擊上面的全選框。下面的所有復(fù)選框都要全選
function chk(obj){
 var chks = document.getElementsByName("chk");
 var len = chks.length;
 for(var i=0; ilen; i++){
  chks[i].checked = obj.checked;
 }
}
//通過統(tǒng)計下面的復(fù)選框的選擇情況,決定上面的復(fù)習框的三種狀態(tài)
function subchk(obj){
 var chks = document.getElementsByName("chk");
 var n=0; //統(tǒng)計表格行中被勾選中的行數(shù)
 for(var i=0;ichks.length;i++){
  if(chks[i].checked){
   n++;
  }
 }

 var parentChk = document.getElementById("parentChk");
 if(n==0){
  parentChk.indeterminate=false;//※※※不能省
  parentChk.checked=false;
 }else if(n==chks.length){
  parentChk.indeterminate=false;//※※※不能省
  parentChk.checked=true;
 }else{
  parentChk.indeterminate=true;
 }

}

//把用戶選中行的id提交給后臺,后臺刪除成功后返回true
function del(){
 //以后我們應(yīng)該用json去封裝所有的id,提交給后臺處理(暫時我們還沒學)。
 //現(xiàn)在我們暫時用字符拼接的方式來做,有潛在bug的
 var tb = document.getElementById("tb");
 var chks = document.getElementsByName("chk");

 var ids="";
 for(var i=0;ichks.length;i++){
  if(chks[i].checked){
   //alert("aaa");
   //把該行的id值獲取出來
   var oTr = chks[i].parentNode.parentNode;
   //alert(oTr);
   var id = oTr.cells[4].innerText;
   //alert(id);

   if(ids==""){
    ids=id;
   }else{
    ids = ids +"," +id;
   }
  }
 }

 if(ids==""){
  alert("請選擇要刪除的行");
 }else{
  document.getElementById("ids").value=ids;
  document.forms['f1'].submit();
 }
}

function realDel(boo){
 if(!boo){
  alert("刪除失敗!");
  return;
 }

 var tb = document.getElementById("tb");
 var chks = document.getElementsByName("chk");
 var len = chks.length;
 //倒著刪
 for(var i=len-1;i>=0;i--){
  if(chks[i].checked){
   tb.deleteRow(i+1);
  }
 }

 var chks = document.getElementsByName("chk");
 var n=0; //統(tǒng)計表格行中被勾選中的行數(shù)
 for(var i=0;ichks.length;i++){
  if(chks[i].checked){
   n++;
  }
 }
 // 刪除之后更細上面復(fù)選框的狀態(tài)
 var parentChk = document.getElementById("parentChk");
 if(n==0){
  parentChk.indeterminate=false;//※※※不能省
  parentChk.checked=false;
 }else if(n==chks.length){
  parentChk.indeterminate=false;//※※※不能省
  parentChk.checked=true;
 }else{
  parentChk.indeterminate=true;
 }


}

input.jsp

%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
html>
 body>
  h3>客戶信息添加/h3>
  form target="ifrm" name="ss" action="c:url value='/SaveServlet' />" method="post">
   姓名:input type="text" name="name"/>br/>
    年齡:nbsp;input type="text" name="age"/>br/>
    地址:input type="text" name="addr"/>br/>br/>
   input type="button" value="添加" onclick="save();"/> nbsp;nbsp;
   input type="button" value="取消" onclick="window.close();"/>br/>
  /form>

  iframe name="ifrm" style="display:none;">/iframe>

 script type="text/javascript">
  function save(){
   document.forms['ss'].submit();
  }

  //該方法由后臺返回的saveback.jsp(在iframe中,子頁)反調(diào)這里(父頁)
  function realSave(obj){
   //window.returnValue="aa";
   //window.close();
   window.returnValue=obj;
   window.close();
  }
 /script>
 /body>
/html>

save.jsp

%@ page language="java" import="java.util.*;" pageEncoding="UTF-8"%>
%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
script type="text/javascript">
 var user = new Object();
 user.name = 'c:out value="${user.name}"/>';
 user.id = 'c:out value="${user.id}"/>';
 user.age = 'c:out value="${user.age}"/>';
 user.addr = 'c:out value="${user.addr}"/>';
 parent.realSave(user);
/script>

在后面是刪除的過程

delback.jsp

%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
script type="text/javascript">
 //用jstl在js頁面中把從后臺獲取出來
 var boo = "c:out value='${succ}' />";
 parent.realDel(boo);
/script>

更多學習資料請關(guān)注專題《管理系統(tǒng)開發(fā)》。

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • VueJS實現(xiàn)用戶管理系統(tǒng)
  • Node.js實現(xiàn)簡單管理系統(tǒng)
  • jdbc+jsp實現(xiàn)簡單員工管理系統(tǒng)
  • JSP實現(xiàn)簡單人事管理系統(tǒng)
  • JSP學生信息管理系統(tǒng)設(shè)計
  • 詳解nodejs中express搭建權(quán)限管理系統(tǒng)
  • 基于jsp實現(xiàn)新聞管理系統(tǒng) 附完整源碼
  • 如何使用AngularJs打造權(quán)限管理系統(tǒng)【簡易型】
  • JSP學生信息管理系統(tǒng)
  • js實現(xiàn)車輛管理系統(tǒng)

標簽:南京 廣州 大連 黃石 貸款邀約 銅川 樂山 內(nèi)江

巨人網(wǎng)絡(luò)通訊聲明:本文標題《JSP實現(xiàn)客戶信息管理系統(tǒng)》,本文關(guān)鍵詞  JSP,實現(xiàn),客戶,信息,管理系統(tǒng),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《JSP實現(xiàn)客戶信息管理系統(tǒng)》相關(guān)的同類信息!
  • 本頁收集關(guān)于JSP實現(xiàn)客戶信息管理系統(tǒng)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    江山市| 茂名市| 临朐县| 灵山县| 建宁县| 平江县| 双牌县| 年辖:市辖区| 上高县| 青田县| 安宁市| 天柱县| 临高县| 德庆县| 廉江市| 漳州市| 新巴尔虎右旗| 沂源县| 岳阳市| 武汉市| 江孜县| 介休市| 兴海县| 临海市| 桐柏县| 东方市| 治多县| 应城市| 嫩江县| 紫云| 廊坊市| 柞水县| 彭州市| 乐清市| 怀宁县| 扎赉特旗| 崇义县| 手游| 黄平县| 宣威市| 青阳县|