下面是我的 Spring Controller 代码。我的目的是将变量 int a、int b、int c 的值传递给 Jsp 页面 ADMINRESULTS。
请注意,这些变量的值将用于在 adminhome jsp 页面中初始化 javascript 变量
@RequestMapping("/adminresults") //this is called by form action. This does not refer to adminhome jsp page
public String adminhome(Map<String, Object> model) {
ArrayList<Block> blockChain = NoobChain.getBlockChain();
Map<String, Integer> dataMap = new HashMap<String, Integer>();
if (!blockChain.isEmpty()) {
if (!NoobChain.isChainValid(blockChain)) { //if not valid to print the data.
model.put("tampermsg", "Unathorized acess detected and vote data is attacked.Correct values are ");
dataMap = NoobChain.validChainData(blockChain);
} else {
dataMap = blockChain.get(0).getData();
}
}
String blockchainJsonFromFile = new GsonBuilder().setPrettyPrinting().create().toJson(blockChain);
System.out.println("after.." + blockchainJsonFromFile);
model.put("message", "\n" + dataMap);
System.out.println("Before extracting DATA is "+dataMap);//to check the format of data map
int a=0;
int b=0;
int c=0;
if (dataMap.containsKey("A"))
{
a = dataMap.get("A");
System.out.println("value for key \"A\" is:- " + a);
}
if (dataMap.containsKey("B"))
{
b = dataMap.get("B");
System.out.println("value for key \"B\" is:- " + b);
}
if (dataMap.containsKey("C"))
{
c = dataMap.get("C");
System.out.println("value for key \"C\" is:- " + c);
}
model.put("a", a);
model.put("b", b);
model.put("c", c);
我的意图是将上述变量初始化为,bs,cs 与 int a,int b,int c(来自上面提到的 Spring 控制器)
千万里不及你
江户川乱折腾
四季花海
随时随地看视频慕课网APP
相关分类