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

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

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

org.apache.subversion.javahl.ClientException: The working copy needs to be upgraded svn: Working cop

org.apache.subversion.javahl.ClientException: The working copy needs to be upgraded svn: Working cop

SVN更新出现问题:org.apache.subversion.javahl.ClientException: The working copy needs to be upgraded svn: W...

js/jquery 实现点击图片更换头像(图片)实例

    总之一句话, 可以先将 file类型 的input 隐藏 起来,通过 图片(头像)的onclick事件 来触发 file 的onclick事件。1.引入外部js:...

太阳的后裔 经典对白(羞羞哒)

太阳的后裔 经典对白(羞羞哒)

关于电视剧 ,小编常说早就戒了,但是好剧呢还是要追滴。太阳的后裔, 追剧追到12集了,开始都是宋仲基比较调皮:我很想问你一件事情。什么都不要问,你知道我要问什么。看你现在一脸都是很想嘲笑我的表情。哪有...

jquery 操作html元素(及CSS)

jquery 操作html元素(及CSS)

 $("li").addClass("aui-user-view-cell aui-img") ;  //给元素添加样式$('#a1...

评论列表

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

萨瓦迪卡,看不懂呀

发表评论

访客

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