我正在研究Java项目。 我想修改html代码以在java类中显示一些额外的变量。 其中之一是静态整数。
Java类代码:
public class AuctionContext {
public static enum AuctionType {SAA, CCA, LUA};
private AuctionType type;
private int round;
private int duration_ms;
private ArrayList<AuctionItem> itemList;
private double minIncreament;
//priceTick is used in CCA and LUA auction, keep track of current
price for all items.
private double priceTick = 0;
private boolean finalRound;
public static int numberOfActivityRuleWaivers = 2;
private boolean activityRuleAnnounced = false;
private int activityRuleStartRound = -1;
private int test=15;
private int summElig;
变量numberOfActivityRuleWaivers
是我要在html页面中显示的内容。
xml中写入静态变量的部分:
child = doc.createElement("waivers");
child.setAttribute("value", Integer.toString(numberOfActivityRuleWaivers));
root.appendChild(child);
html代码(其中显示双括号和放弃的部分):
<polymer-element name="auction-saa">
<template>
<link rel="stylesheet" href="./auction-saa.css" type="text/css" />
<div id="auction-saa">
<div class="title">
<p>SAA - <span>Round {{ round }}</span></p>
</div>
<div id="box">
<p id="time"></p>
<p id="timeduration"> Minimum Increment: {{ minimumIncreament }} </p>
<p id="waivers"> Number of Waivers {{waivers}}</p>
<p id="warning"></p>
<p id="activityruleannouncement"></p>
<p id="leadingitems"></p>
<p id="activityandeligibility"></p>
和javascript(我将其初始化并稍后在函数中构建):
Polymer('auction-saa', {
waivers:-1,
test:-1,
displaywaivers:function()
{ this.summElig = this.saa.summElig;
},
我在大括号和xml的值中使用了相同的词。 当我运行此代码时,html显示0,但实际数字应为2。任何非静态字段都正确显示。你能帮我吗?