现在的位置: 首页 > 综合 > 正文

银保项目总结2014.8.22

2018年01月31日 ⁄ 综合 ⁄ 共 6578字 ⁄ 字号 评论关闭

自我分析见证自己的成长..
银保项目总结:
1.开发前没有系统的分析所有的流程
2.思考问题思路不清晰
3.很多东西忘记了,导致效率底下,开发工具使用,不熟悉

学习技巧:
一旦有一个操作,就要分析操作的所有流程;
所有的web项目都是
1.验证数据
2.清除数据
3.获值(jquery)
4.传入后台(form表单,ajax,a标签href,action)
5.后台处理传入数据库
6.数据库db操作函数,复用select_paramIndex_returnParam
7.传值(out.print())
8.显示
以上步骤全部基于:操作
1.每一个操作,都要分析每一种可能
2.非法操作(前台),失败操作(后台),成功操作(后台)

JQUERY
对JQUERY的理解 都是通过先地位,再筛选,然后改变状态
$("#parentid child[attr=attrValue]")
  .attr("attrName","attrValue)
  .css("cssName","cssValue")
  .html("htmlValue");

JQUERY AJAX JSON知识
1.jquery.js,json.js,json6个包
2.前台格式
前台
$.ajax({
  url:"test.action",
  data:{name:zhangsan,age:20}   //注意
  type:"post",
  dataType:"json",
  success:function(msg){
   $.each(msg,function(idx,item){
    //... idx遍历数,item当前遍历信息;
   })
  }
})
3.后台格式
后台
responsesetContentType("text/javascript;charset=gbk");      //注意
//单个
out.print(JSONObject.fromObject("{name:'zhangsan',age:'20'}").toString());    //注意
//数组
ArrayList<String> list =new ArrayList<String>();
list.add("{name:'zhangsan',age:'20'}");
list.add("{name:'lisi',age:'21'}");
out.print(JOSNArray.fromObject(list).toString());         //注意

ajax加载数据过大几千条,在IE9中渲染就会变慢 chrome一般在1s左右
$("#table").html()>js>jquery 渲染速度
1.多用id选择器,少用class,用tagName
2.多用链式操作
3.先绑定后插入
$.ajax({
  url:"test.action",
  data:{name:zhangsan,age:20}
  type:"post",
  dataType:"json",
  success:function(msg){
   $.each(msg,function(idx,item){
     var htmlstr = "<tr><td>"+item.name+"</td><td>"+item.age+"</td><td>"+item.hobbit+"</td><td>"+item.height+"</td></tr>";
     $("#table").html(htmlstr);
   })
  }
})

JQUERY获值
$("#select").val();
$("#select option:selected").text();
$("#select").get(0).selectedIndex;

$("#select").val("zhangsan");
$("#select option[text=abc]").attr("selected",true);

//$("#checkbox_parent").change(function(){  相同效果
$("#checkbox_parent").click(function(){
  //$("#checkbox_child").attr("checked",true);  //全选
  //$("#checkbox_child").attr("checked",false);  //全不选
  //$(":checkbox[id=checkbox_child]").attr("checked",$("#checkbox_parent").attr("checked"));  //同步选
  //$(":checkbox[id=checkbox_child]").attr("checked",!$(":checkbox[id=checkbox_child]").attr("checked"));  //不同步选
  //$(":checkbox[id=checkbox_child]").each(function(){;          //反选
  //   $(this).attr("checked",!$(this).attr("checked"));
  //})
  //$(":checkbox[id=checkbox_child]:checked").each(function(){ alert($(this).attr("value")); })//选中的值
  $(":checkbox[id=checkbox_child]").each(function(){ if($(this).attr("checked")==false) alert($(this).attr("value")); })//没选中的值
})
当checkbox有多组时
一个checkbox_parent 和 多个checkbox_child
用$("#checkbox_child")只能获得第一个数据
因为document.getElementById()返回的是单个数据
$(":checkbox[id=checkbox_child]")返回checkbox中所有的id=checkbox_child的数据
使用的是getElementByTagName()返回多个数据;
$.each(function(){
 $(this)   //当前下标对象;
})

小知识:
1.end() 返回上一个操作的元素
2.find()查找子元素
3. .each()中的中断    break  continue 用一下替代
   return false; -->break;
   return true; -->continue;

java正则
Pattern.matches(reg,str);
*-->0
+-->1

一个很方便的验证
//  var reg = /[^0-9]+/g;
 function vali(obj,reg){
  var v = $(obj).val();
  if(reg.test(v)){
   $(obj).val(v.replace(reg,""));
  }
 }

informix数据库
1.select skip M first N name from student;  //分页  M跳过M个数据,取后面N个数据;

2.分组的另一种方法
select name,age from student s1 where name in   //按班级分组得到每个班的人姓名;
(select name from student where class = s1.class );

3.存储过程
------------基本-----
drop procedure pro_test1(int);
create procedure pro_test1(var_num int)
returning int;
define temp1 int;
let temp1=9;
return temp1;
end procedure;         

-------------带有查询 返回值
--drop procedure pro_test(char(50));     -- SHZ31405
--create procedure pro_test(var_num char(50))
--returning char(30);
--define temp1 char(30);
--select  username into temp1  from shz_appusers where userid= var_num ;
--return temp1;
--end procedure;
     
execute procedure pro_test('SHZ31405');

------------------------插入操作-不返回值---------
drop procedure pro_insert(char(30));
create procedure pro_insert(var_num char(30))

define temp_i
insert into shz_appusers(username) values (var_num);
--updata from shz_appusers set userid='1' where username=var_num;
end procedure;

------------------

--------条件----------
IF ( condition ) THEN
   statements
ELIF ( condition ) THEN
   statements
   …
ELSE
   statements
END IF;
--------实例---
drop procedure pro_if(int);
create procedure pro_if(var_if int)
returning char(30);
define result_if char(30);
if var_if = 0 then
let result_if = 'success!';
elif var_if = 1 then
let result_if = 'failed!';
else
let result_if = 'nofind';
end if
return result_if;
end procedure;
execute procedure pro_if(10);

--foreach------------
FOREACH SELECT salary INTO ind_sal
FROM customer
WHERE location = “UK"
sum_sal += ind_sal;
END FOREACH;
RETRUN sum_sal;       6)continue或exit语句
       都可以被使用在for、foreach和while循环语句中。
       参考实例如下:
FOR i = 1 TO 5
   LET j = i;
   WHILE (j > 0)
      LET id = foo(j);
      IF (id = 5) THEN
         LET j = j – 1;
         CONTINUE WHILE; -- 不执行后续的操作,继续回到while循环接着执行
      END IF;
      LET sum = sum + 5;
      LET j = j – 1;
      IF (sum > 500) THEN
         EXIT FOR; -- 退出for循环
      END IF;
   END WHILE;
END FOR;
RETURN sum;
--------实例---
drop procedure pro_foreach;
create procedure pro_foreach(var_foreah int)
returning char(30),char(50);
define un char(30);
define ui char(50);
foreach select username,userid into un,ui  from shz_appusers where userid = var_foreach
end foreach;
end procedure;
------while循环------
WHILE (条件表达式)
   执行的语句
END WHILE;      while中的条件表达式的举例如下:
WHILE (count < 20)
WHILE (status matches "A*")
WHILE (EXISTS (SELECT name FROM customer WHERE cus_num=100))
WHILE (status IN ("A", "I", "D"))
--------实例---
drop procedure pro_while(int);
create procedure pro_while(var_while int)
returning int;
define idx int;
let idx=1;
while var_while < 100
let idx=idx+1;
let var_while=var_while+1;
end while;
return idx;
end procedure;
execute procedure pro_while(10);
--循环-for----
FOR count = 2 TO 30
FOR count = 2 TO 30 STEP 2
FOR count IN ( 2, 5, 7, 9)
FOR count IN ( 2 to 8 STEP 2, 12 to 19, 22)
FOR name IN ("AMY", "MAX",
(SELECT name FROM customer WHERE customer_num = 100) )
--------实例---
drop procedure pro_for(int);
create procedure pro_for(var_i int)
returning int;
define i int;
for i=1 to 10
let var_i=var_i+1;
end for
return var_i;
end procedure;
execute procedure pro_for(10);

---------------返回多行值  游标---------------------------------
drop procedure pro_dele;
create procedure pro_dele()
define p_time date;
begin work;
foreach curl for
--update游标必须命名
select time_stamp into p_time from pro_dele_tbl
where num > 100
if p_time is not null then
delete from pro_del_tbl where current of curl;
--删除当前记录
end if;
end foreach;
commit work;
--所有修改记录的锁被释放。
end procedure;
---------------返回多行值with resume---------------------------------
drop procedure count_add;--删除存储过程
create procedure count_add(user_name_var varchar(50) default 'administrator')
--user_name_var传递参数变量在此定义
returning varchar(50);
--返回一个字符型的值
define error_count_var integer;
----定义输入的次数变量
select error_count into error_count_var from users where user_name=user_name_var;
----error_count默认是0,从0开始记数
let error_count_var=error_count_var+1;
----输入一次记数加1
update users set error_count= error_count_var where user_name =user_name_var ;
return user_name_var;
--返回变量值,与returning对应。
return user_name_var WITH  RESUME;
----将保证存储过程继续执行,所有的变量均保持原有的值
end procedure

抱歉!评论已关闭.