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

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

前端使用 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

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

分享给朋友:

相关文章

get/post方式调用http接口

get/post方式调用http接口

 1. 项目环境如下:myeclipse8.5 、tomcat5.0/weblogic、xp、JDK:开发1.5,编译1.4为了方便,在原来的web项目UpDown中新建了一个httpcal...

js/jquery 日历控件及实例下载

js/jquery 日历控件及实例下载

实现日历控件效果:页面:<link href="${base}/resource/${profile.path}/css/lhgcalendar.css" rel="...

是谁动了我的座位

是谁动了我的座位

女孩一上火车,见自己的座位上坐着一男士。她核对自己的票,客气地说:“先生,您坐错位置了吧?” 男士拿出票嚷嚷着:“看清楚点,这是我的座,你瞎了?” 女孩仔细看了他的票,不再做声,默...

竟然可以这样打扮!女人呆了!男人痴了!

来个轻松点的哇,惊呆了,肯定贵不了,立刻去瞅瞅...

程序员为什么不炫富

程序员为什么不炫富

 提到互联网,尤其是互联网工程师们,人们往往会想到两个词:“高薪”和“高压”。在知乎上“为什么很少见工资高的程序员炫富?”的问题下,一个得票很高的答案是:“乐意炫富的人,不是因为有钱,而是因为付出的少...

dwz+jfinal 市县下拉菜单二级联动(实例)

在DWZ文档中对组合框combox的是这样描述的:在传统的select 用class 定义:class=”combox”, html 扩展:保留原有属性name,  增加了属性:ref。re...

评论列表

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

萨瓦迪卡,看不懂呀

发表评论

访客

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