Velocity模板和Java字符串

3

我是一位有用的助手,可以帮您进行文本翻译。

我开发了Jira报表插件。Velocity模板在Java字符串中显示ASCII代码的单引号或双引号。

Java代码:

Main:

    Map velocityParams = new HashMap();
    String horizontalAxis = convertKeysToWeekCategories(bugtrends.keySet());

    velocityParams.put("horizontalAxis", horizontalAxis);

convertKeysToWeekCategories method:

    StringBuilder build = new StringBuilder();

    for (Integer integer : keySet) {
        build.append("\'");
        build.append("W");
        build.append(integer.toString());
        build.append("\'");
        build.append(",");
    }

    String result = build.toString();

    result = result.substring(0, result.length() - 1);

    return result;

}

And I draw with HighChart api.

bugstrendview.vm:

<head >
    <meta charset="utf-8">
</head>

<script>AJS.$(document).ready(function(){ 


    chart = new Highcharts.Chart({

        chart: {
            type: 'spline',
            renderTo: 'container'
        },
        exporting: {
            enabled: true,
            filename: "open-bugs-trend-chart"
        },
        title: {
            text: 'Open Bugs Trend',
            x: -20 //center
        },
        subtitle: {
            text: 'results are displayed in weeks',
            x: -20 //center
        },
        xAxis: {
            categories: [$horizontalAxis],
            labels: {
                rotation: -90,
                align: 'right',
                style: {
                    fontSize: '13px',
                    fontFamily: 'Verdana, sans-serif'
                }
            }
        },

        tooltip: {

        formatter: function() {
            var myDates = $tooltipDates;
            return "<b>W"+(this.point.x+1)+"</b><br/>"+
            myDates[this.point.x]+" - "+myDates[this.point.x + 1]+
            "<br/>"+"Total Bugs : "+this.point.y ;

        },
    },


        yAxis: {
            gridLineWidth: 1,
            minorGridLineWidth: 1,
            title: {
                text: 'Number of Open Bugs'
            },
            min: 0,
            plotLines: [{
                value: 0,
                width: 1,
                color: '#808080'
            }]
        },
        plotOptions: {
            spline: {
                dataLabels: {
                    enabled: true
                },
                marker: {
                    enable: true
                }
            }
        },
        series: [
        {
            showInLegend: false,
            data: [$verticalAxis]
        }]
    });        });

</script>

在bugstrendview.vm中显示的类别为:&#39;W1&#39;,错误为“未捕获的SyntaxError:意外的标记&'”,当然也不会绘制。

为什么显示单引号的ASCII码?


你从文档或文本文件中复制了什么吗? - Nishith Kant Chaturvedi
我没有完全理解你的问题。这个插件适用于Jira 5,但不适用于Jira 6.4.9。 - Anıl Sevici
1个回答

1

谢谢回答。这个有效!!今天我学到了一些关于速度的东西。 - Anıl Sevici
不幸的是,对我来说添加 WithHtml 似乎没有任何效果。 - Ryan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接