<form method= "post " action= "reg.jsp ">
<input type= "text " name= "reg " values= "action " />
<input type= "submit " name= "Submit " value= "确定 ">
</form>
<%
String reg;
reg=request.getParameter( "reg ");
if (reg== "action ")
{
out.print( "ok ");
}
%>
为什么打印不出 ok字串
------解决方案--------------------
判断方法改成:
if (reg.equals( "action "))
{
out.print( "ok ");
}
------解决方案--------------------
又被楼上抢先了,string类型用equals比较的
------解决方案--------------------
== 比对 对象 是否相同
equals 比较 值 是否相同