Java 实现用户资料完整度的前端显示(或根据填写资料自动评分)

1549年前 (2016-05-10)java技术4557

前端使用 Bootstrap 的进度条组件显示百分比,后台读取权重并计算信息完整度,并将计算的结果返回给前端,供页面显示。

CSS

1
<link href="static/sc/css/bootstrap.min.css" rel="stylesheet">

JS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<script src="static/sc/js/jquery-1.9.1.js"></script>  
<script src="static/sc/js/bootstrap.min.js"></script>  
   
<script language="javascript">  
 $(function() {  
    // 加载页面时,动态读取个人资料完整度  
     $.ajax({  
            async: false,  
            url : 'getInfoDegree.do',  
            type : 'POST',  
            dataType : 'json',  
            data : {},  
            error : function(XmlHttpRequest, textStatus, errorThrown) {  
                alert("服务器错误:" + XmlHttpRequest.status  
                        " " + XmlHttpRequest.statusText + '!');  
            },  
            success : function(data) {  
                if (!data)  
                    return;  
                if(data.flag == "true"){  
                    $("#showSpan").html(data.degree);  
                    $("#showBar").css("width", data.degree);  
                    $("#showPercent").html(data.degree);  
                }else if(data.flag == "false"){  
                    $("#infodegree").html(data.desc);  
                    return false;  
                }  
            }     
        });  
 });  
</script>

DOM

1
2
3
4
5
6
7

<p style="color:#666;">个人资料完整度:

<span id="showSpan" style="color:#ff9933;font-size:20px;font-weight:bold;"></span></p>  

  <div class="progress progress-striped" style="width:210px;height:15px;">  

    <span style="white-space:pre">    </span>

    <div id="showBar" class="progress-bar progress-bar-info" role="progressbar"aria-valuenow="60" aria-valuemin="0" aria-valuemax=     "100" >  

       <span style="white-space:pre">        </span>

       <span id="showPercent" class="sr-only"></span>  

       <span style="white-space:pre">    </span>

    </div>  

  </div>  
<em id="infodegree"></em>

后台

Java(部分代码)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/** 
 * 根据权重计算资料完整度 
 * @param map 
 * @return 
 */  
private String getInfoDegree(List<TScAcntProp> list) {  
    int sum = 0;  
    if (list.size() > 0) {  
        // 遍历权重配置文件,获取权重  
        for (int i = 0; i < list.size(); i++) {  
            int degree = Integer.parseInt(CommonUtil.getProperty(list.get(i).getPLabelName()));  
            sum += degree;  
        }  
    }  
    // 返回计算后的权重  
    return sum + "%";//自动评分的话 就去掉%即可

配置文件

config.properties配置文件中存放的是表字段的所占权重。在config.properties里加入一下内容


channel.name=5
channel.owner=5
channel.telphone=5
channel.man=5
channel.email=10
channel.pic=10
channel.earning=10
channel.pronum=10
channel.expnum=10
channel.way=10
channel.plan=10
channel.budget=10

本文原创,转载必追究版权。

分享给朋友:

相关文章

java将金额转化为大写金额

 private static String[] num = {"零","壹","贰","叁","肆...

plsql 中number类型字段 取消科学计数法显示

 PL/SQL DEVELOPER中禁用科学计数法:Tools - Prefrence - SQL Window - 选择:"Number fields to_char&quo...

org.tigris.subversion.javahl.ClientException:Attempted to lock an already-locked dir

 svn更新或提交时候报错:org.tigris.subversion.javahl.ClientException:Attempted to lock an already-locke...

java解析JSON 数组数据 实例

 public  static void main (String args[]){  String sJson ="[{'acceptTim...

MyEclipse 8.5 新建 基于Xfire的webservice

MyEclipse 8.5 新建 基于Xfire的webservice

 使用Xfire实现Web Services,作业应当包括相关的实现软件代码以及对应的WSDL。 MyEclipse 8.5,XFire 1.2.6,weblogic 11g/TomcatX...

freeMarker Jfinal 获取session里的值

问题:freeMaker session取值的常用格式都试过 session["xxx"],session.xxx 直接xxx 都取不出来?????解决:JFinal与Struts...

评论列表

工控资料窝
工控资料窝
9年前 (2016-09-22)

萨瓦迪卡,看不懂呀

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。