如果我有像...这样的哈希表。
$theHash = @{"dog"="mean"; "cat"="nice";"bird"="annoying"}
我可以通过以下方式获取值的关键字:
$theHash."dog"
我该如何反过来?我想提出类似的东西,"意思是"得到"狗"作为输出?因此,如果我只知道"意思是",我该如何从中得到狗?
答案 0 :(得分:4)
String from = request.getParameter("from");
String to = request.getParameter("to");
String step = request.getParameter("step");
**String convert = request.getParameter("convert");**
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
out.println("convert: " + convert);
int fromCount = 0;
int toCount = 0;
int stepCount=0;
boolean badValues = false;
try {
fromCount = Integer.parseInt(from);
toCount = Integer.parseInt(to);
stepCount = Integer.parseInt(step);
} catch (NumberFormatException e) {
badValues = true;
}
if (badValues) {
out.println("<strong style=\"color:red\">All Fields should be Integer</strong>"
+ " <br>\n"
+ "<a href='../FormDemo.html'>Back to the form</a>");
}
else
**if (convert=="cf") {
printTable(out, fromCount, toCount, stepCount);
}
else
printTable2(out, fromCount, toCount, stepCount);
}**