我有以下问题 - if else 语句在 JSP 中不起作用,老实说我不知道为什么。基本上,我尝试placeName
根据存储在名为 place 的字符串中的数字来更改。在浏览器中打印值后,我可以看到值没有改变。我敢肯定这很简单,但是……也许有人以前遇到过类似的问题?
<%
//requests the strings sent by previous page
String year = request.getParameter("year");
String place = request.getParameter("place");
out.print(year);
out.print(place);
String year2 = request.getParameter("year2");
String place2 = request.getParameter("place2");
//out.print(year2);
//out.print(place2);
if (place == "1")
{
placeName = "Belmullet";
}
else if (place == "2")
{
placeName = "Birr";
}
...more statements here...
else if (place == "15")
{
placeName = "Shannon airport";
};
%>