知识点杂记2

前端之家收集整理的这篇文章主要介绍了知识点杂记2前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
1.fusionchart的使用方法 fusionchart的显示的两种方式的总结 方法1:通过form将xml从后台传到前台 <script type="text/javascript" src="<%=host%>/thirdparty/fusioncharts/js/FusionCharts.js"></script> ····· <html:hidden name="scoreYhdjltjActionForm" property="bztXML" styleId="bztXML" /> ····· <td align="center"> <div id="chartdiv" align="center">教师点击量详情</div> <script type="text/javascript"> var chartWidth = window.document.body.offsetWidth-400; var bztchart = new FusionCharts("<%=host%>/thirdparty/fusioncharts/swf/Pie2D.swf","ChartId",chartWidth,"360","0","0"); var xmlStr = $("#bztXML").val(); bztchart.addParam("wmode","Opaque"); if($.trim(xmlStr)==''||xmlStr==null){ $("#chartdiv").html("暂无数据"); } if(bztchart!=null){ bztchart.setdataxML(xmlStr); } bztchart.render("chartdiv"); </script> </td> 方法2:通过ajax方式 -------前台-------------- <script type="text/javascript"> var host = "<%=host%>"; var zygxId = "<%=zygxId%>"; var bjId ="<%=bjId_hh%>"; $(document).ready(function(){ var chartWidth = document.getElementById("chartdiv").offsetWidth; var chart = new FusionCharts("<%=host%>/fusionCharts/MSColumn3D.swf","myChartId","300","1"); chart.addParam("wmode","Opaque"); $.ajax({ type:"post",url: "<%=host%>/fzkt/resultStatAction.do?operFlag=statChart&zygxId="+zygxId+"&bjId="+bjId,cache: false,success: function(data){ var datajson = eval("["+data+"]"); var xmlStr = datajson[0].xmlStr; var tableStr = datajson[0].tableStr; if($.trim(xmlStr)==''||xmlStr==null){ $("#chartdiv").html("该课程下暂时没有学生答题"); return; } if(chart!=null){ chart.setdataxML(xmlStr); } chart.render("chartdiv"); document.getElementById("tableDiv").innerHTML = ""; document.getElementById("tableDiv").innerHTML = tableStr; } }); function tubiao(){ $.ajax({ type:"post",success: function(data){ var datajson = eval("["+data+"]"); var xmlStr = datajson[0].xmlStr; var tableStr = datajson[0].tableStr; if($.trim(xmlStr)==''||xmlStr==null){ $("#chartdiv").html("该课程下暂时没有学生答题"); return; } if(chart!=null){ chart.setdataxML(xmlStr); } document.getElementById("tableDiv").innerHTML = ""; document.getElementById("tableDiv").innerHTML = tableStr; } }); } setInterval(tubiao,5000); }); <body style="height:100%;width:90%;overflow: auto;overflow-x:hidden;"> <div id="chartdiv" align="left" ></div> <div id ="tableDiv" align="left"></div> </body> ------后台------- /** * 初始化答题结果统计页面 */ private ActionForward resultStat(ActionMapping mapping,ResultStatActionForm resultStatActionForm,HttpServletRequest request,HttpServletResponse response){ //ActionForward forward = mapping.findForward("statChart"); String zygxId = resultStatActionForm.getZygxId(); // 获取统计答题结果的资源Id String bjId = resultStatActionForm.getBjId(); //获取指定资源Id下要统计答题结果的班级Id ResultStatBO resultStatBO = new ResultStatBO(); // 答题结果统计业务处理BO String resultStatXML = ""; try { if("".equals(zygxId)){ User user = UserUtil.getLoginUser(request); zygxId = ZygxBO.getZygxBO().getMaxZygxId(user); } resultStatXML = resultStatBO.getResultStatXML(zygxId,bjId); String resultStatTableStr = resultStatBO.getResultStat(zygxId,bjId); response.setCharacterEncoding("gbk"); JSONObject jsonObj = new JSONObject(); jsonObj.put("xmlStr",resultStatXML); jsonObj.put("tableStr",resultStatTableStr); response.getOutputStream().write(jsonObj.toString().getBytes("gbk")); } catch (Exception e) { // 异常处理 this.exceptionOperate(request,this.getClass(),e,operFlag); } finally { // 资源释放 BaseResourceContainer.releaseAllResource(); } // 将获取到xml数据填充到Form中 //resultStatActionForm.setResultStatXML(resultStatXML); return null; } ------bo层xml加超链接的两种方式-------- (1)sbXML.append("<set value='"+falut+"' tooltext='练习"+(j+1)+",错题人数:"+falut+"' link='j-cuotimingxi-"+lxtId+"'/>"); (2)jfXML.append("<set label='"+jsjfPHPO.getJsmc()+"' value='"+jsjfPHPO.getZjf()+"' link= \" " + "javascript:jfxq('"+jsjfPHPO.getSfz()+"','"+jsmc+"')\" "+"/>"); -------bo层相关重要属性设置-------- /** * 获得柱状图xml * */ public String getJsjfchartXML(Page page,scoreJsjfphQO jsjfphQO) throws DataAccessException,UnsupportedEncodingException { scorejfmxDAO jfmxDAO = scorejfmxDAO.getJfmxDao(); //单例模式 List<scoreJsjfPHPO> jflist = jfmxDAO.getJsjfList(page,jsjfphQO); //获得教师积分list StringBuffer jfXML = new StringBuffer(); if(jflist!=null&&jflist.size()>0){ //baseFontSize设置字体大小;unescapeLinks='0'解决link传中文字符时出现乱码; jfXML.append("<chart caption='教师积分排行榜' xAxisName='教师姓名' yAxisName='积分' showValues='0' decimals='0'" + " formatNumberScale='0'useRoundEdges='1' baseFontSize='12' unescapeLinks='0'>"); for(scoreJsjfPHPO jsjfPHPO :jflist){ String jsmc = URLDecoder.decode(jsjfPHPO.getJsmc(),"UTF-8"); jfXML.append("<set label='"+jsjfPHPO.getJsmc()+"' value='"+jsjfPHPO.getZjf()+"' link= \" " + "javascript:jfxq('"+jsjfPHPO.getSfz()+"','"+jsmc+"')\" "+"/>"); } } jfXML.append("<styles>") .append("<definition><style name='CaptionFont' type='font' size='13'/></definition>") .append("<application><apply toObject='XAXISNAME' styles='CaptionFont' /><apply toObject='YAXISNAME' styles='CaptionFont' />") .append("<apply toObject='CAPTION' styles='CaptionFont' /></application>") .append("</styles>"); jfXML.append("</chart>"); return jfXML.toString(); } ============================================================================================================================================================================= 2.解决URL传中文字符出现乱码问题 --------前台-------- 将中文字符加两次码:encodeURI(encodeURI(jsmc)) //积分详情 function jfxq(sfz,jsmc){ var source = $("#source").val(); var ksrq = $("#ksrq").val(); var jsrq = $("#jsrq").val(); var surl="<%=request.getContextPath()%>/score/scoreJsjfphAction.do?operFlag=jfxq&jsjfphQO.sfz="+ sfz+"&source="+source+"&jsjfphQO.ksrq="+ksrq+"&jsjfphQO.jsrq="+jsrq+"&jsjfphQO.xm="+encodeURI(encodeURI(jsmc))+"&Rnd="+Math.random(); window.showModalDialog(surl,"newwindow","dialogWidth=600px;dialogHeight=350px;scroll=no;"); } --------后台------- 将传过来的中文字符解码一次: String xm = form.getJsjfphQO().getXm(); xm = URLDecoder.decode(xm,"UTF-8"); form.getJsjfphQO().setXm(xm); ============================================================================================================================================================================= 3.前台计算表格中某一列数字的总和 ------列1------ <td class="jsdjltd" nowrap="nowrap" align="center" height="30"> <a onclick="jsdjlxq('<bean:write name="data" property="ywdm" />','<bean:write name="data" property="ywmc" />')"><bean:write name="data" property="jsdjl" /></a> </td> ------列2------ <td class="jzdjltd" nowrap="nowrap" align="center" height="30"> <a onclick="jzdjlxq('<bean:write name="data" property="ywdm" />','<bean:write name="data" property="ywmc" />')"><bean:write name="data" property="jzdjl" /></a> </td> ------列3------ <td class="zdjltd" nowrap="nowrap" align="center" height="30"> <bean:write name="data" property="zdjl" /> </td> -----计算列1的和------ <td id = "jshjdjl" nowrap="nowrap" align="center" height="30"> <script type="text/javascript"> var zjs=0; var jszdjl=$(".jsdjltd"); jszdjl.each(function(){ zjs = zjs + parseInt( $(this).text()); }); $("#jshjdjl").text(zjs); </script> </td> ----·循环计算多行的和------ <td id= "hjdjl" nowrap="nowrap" align="center" height="30"> <script type="text/javascript"> var z=0; var zdjl=$(".zdjltd"); //each的用法 zdjl.each(function(){ z = z + parseInt( $(this).text()); }); $("#hjdjl").text(z); </script> </td> ============================================================================================================================================================= 4.公司框架时间控件的用法 <script type="text/javascript" src='<%=host%>/thirdparty/My97DatePicker/WdatePicker.js'></script> <td width="25%"> <param:select type="jyjxxnewTag" name="scoreYhdjltjActionForm" nullStr="" property="yhdjltjQO.xxdm" condition="yhdjltjPO.jyjdm" styleId="xxdm" style="width:280px;height:28px;line-height:28px;"/> </td> <td width="50%" > <common:text name="scoreYhdjltjActionForm" property="yhdjltjQO.ksrq" validator="date(yyyy-mm-dd)" empty="true" styleId="ksrq" value="" size="14" label="" maxlength="10" style="width:100px;height:28px;line-height:28px;" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})" styleClass="Wdate"/> &nbsp;&nbsp;至&nbsp; <common:text name="scoreYhdjltjActionForm" property="yhdjltjQO.jsrq" validator="date(yyyy-mm-dd)" empty="true" styleId="jsrq" value="" size="14" label="" maxlength="10" style="width:100px;height:28px;line-height:28px;" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})" styleClass="Wdate"/> </td> -----普通时间控件---- <input style="width:100px;height:25px;line-height:25px;" class="Wdate" type="text" onClick="WdatePicker()"><font style='display:none' color=red id='gzrqstart_empty' >*</font> &nbsp;&nbsp;至&nbsp;&nbsp; <input style="width:100px;height:25px;line-height:25px;" class="Wdate" type="text" onClick="WdatePicker()"><font style='display:none' color=red id='gzrqend_empty'>*</font> ============================================================================================================================================================= 5.公司框架select标签用法 //nullStr属性让初始值为空;condition属性查询select数据所需的条件 <td width="25%"> <param:select type="jyjxxnewTag" name="scoreYhdjltjActionForm" nullStr="" property="yhdjltjQO.xxdm" condition="yhdjltjPO.jyjdm" styleId="xxdm" style="width:280px;height:28px;line-height:28px;"/> </td> ------级联------ <td class="name">年级&nbsp;&nbsp;</td> <td class="fill"> <param:select type="xx_njTag" name="fzktzhktActionForm" property="wjtjQO.njid" styleId="njid" nullStr=" " condition="wjtjQO.xxdm,wjtjQO.xn,wjtjQO.xq" label="请选择年级" onchange="chag()"/> </td> <td class="name" style="align:left;">班级&nbsp;&nbsp;</td> //notifier属性,级联年级 <td class="fill"> <param:select type="xx_bjTag" name="fzktzhktActionForm" property="wjtjQO.bjid" styleId="bjid" nullStr=" " label="请选择班级级" notifier="njid" /> </td> -----普通select标签------- <select style="width:150px;height:26px;line-height:26px;"> <option value="1">A中学</option> <option value="2">B中学</option> <option value="3">C中学</option> </select> ============================================================================================================================================================= 6.判断只能输入数字的方法 ------方法1------ function validate(){ var reg = new RegExp("^[0-9]*$"); var ksjfz = document.getElementById("ksjfz"); var jsjfz = document.getElementById("jsjfz"); if(!reg.test(ksjfz.value)||!reg.test(jsjfz.value)){ alert("请输入数字!"); } if(!/^[0-9]*$/.test(ksjfz.value)||!/^[0-9]*$/.test(jsjfz.value)){ alert("请输入数字!"); } } ------方法2-------- 输入框中使用 用正则表达式:onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" <common:text name="scoreJzjfphActionForm" property="jzjfphQO.ksjfz" empty="true" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" validator="text(1,60)" styleId="ksjfz" size="10" maxlength="60" label="" /> ============================================================================================================================================================ 7.list的创建 private List<scoreJsjfphQO> jfphbList = new ArrayList<scoreJsjfphQO>();//积分排行list =========================================================================================================================================================== 8.sql语句,排名方式 关键代码:(Select Count(1) + 1 from (select mx.sfz,sum(mx.score) zjf from score_jfmx mx where mx.yxflag = '1' and mx.zhlx = 'Z' group by mx.sfz) Where zjf > t.zjf) pm 示例代码: select jzg.xm jsmc,t.*,(Select Count(1) + 1 from (select mx.sfz,sum(mx.score) zjf from score_jfmx mx where mx.yxflag = '1' and mx.zhlx = 'Z' group by mx.sfz) Where zjf > t.zjf) pm from jcsj_jzgjcxx jzg,(select mx.sfz,sum(mx.score) zjf from score_jfmx mx where mx.yxflag = '1' and mx.zhlx = 'Z' group by mx.sfz) t where jzg.sfz = t.sfz and jzg.yxflag = '1' order by t.zjf desc ===================================================================================================================================== 9.DAO层,添加方法 /**添加“操作记录” * @param source * @param * @return * @throws DataAccessException */ public void czjlAdd( BasescorejfmxPO jfmxPO ) throws DataAccessException { HibernateDataSource data = HibernateDataSource.getHibernateDataSource(); Session session = data.getSession(); StringBuffer sql = new StringBuffer(); sql.append(" insert into score_jfmx") .append(" (ID,SFZ,YWDM,CZLX,score,JFSJ,GXTIME,YXFLAG,GXR,BZ,ZHLX,YWID)") .append(" values") .append(" (SEQ_score_PUB.NEXTVAL,") .append(" '"+jfmxPO.getSfz()+"',") .append(" '"+jfmxPO.getYwdm()+"',") .append(" '"+jfmxPO.getCzlx()+"',") .append(" (select j.score") .append(" from score_zd_jfdy j") .append(" where j.ywdm = '"+jfmxPO.getYwdm()+"'") .append(" and j.czlx = '"+jfmxPO.getCzlx()+"'") .append(" and j.yxflag = '1'),") .append(" to_date('"+jfmxPO.getJfsjFullStr()+"',yyyy-MM-dd hh24:mi:ss),") .append(" sysdate,") .append(" '1',") .append(" '"+jfmxPO.getGxr()+"',") .append(" '',") .append(" 'Z',") .append(" '"+jfmxPO.getYwid()+"') "); sqlQuery sqlQuery = session.createsqlQuery(sql.toString()); sqlQuery.executeUpdate(); } ============================================================================================================================================== 10.判空为0方法以及,左联方法 select zd.ywdm,zd.ywmc,nvl(jsdjl.jsdjl,0) jsdjl,nvl(jzdjl.jzdjl,0) jzdjl,0) + nvl(jzdjl.jzdjl,0) zdjl from score_zd_yw zd,(select mx.ywdm,count(*) jsdjl from score_mx mx where mx.zhlx = 'Z' and mx.yxflag = '1' and mx.sfz in (select distinct jzg.jzgsfz from xx_jzg jzg) group by mx.ywdm order by mx.ywdm) jsdjl,count(*) jzdjl from score_mx mx where mx.zhlx = 'J' and mx.yxflag = '1' and mx.sfz in (select distinct gx.jzsfz from jcsj_xsjcxx xs,jz_xs gx where xs.sfz = gx.xssfz and xs.yxflag = '1' and gx.yxflag = '1') group by mx.ywdm order by mx.ywdm) jzdjl where zd.ywdm = jsdjl.ywdm(+) and zd.ywdm = jzdjl.ywdm(+) and zd.yxflag = '1' 原文链接:https://www.f2er.com/regex/360817.html

猜你在找的正则表达式相关文章