JSP小错误,谁知道的说下,谢谢先

来源:百度知道 编辑:UC知道 时间:2024/06/10 10:44:22
<%@ page contentType="text/html;charset=GB2312"%>
<html>

<body>
<P>FDSFAFEA
<FORM action="" method="get" name=form>
<INPUT type="submit" value="Yes" name="sumit" />
</FORM>
<% String str=request.getParameter("sumit");
out.println(str);//这边str取出来是NULL,是怎么回事,怎么改
if(str.equals("Yes"))//提示这边出错
{out.println(str);}
%>
</body>
</html>

出的是空指针异常么?
如果是的话,是因为你String str=request.getParameter("sumit");
request里没有叫sumit的变量
你在判断时可以这样写 "Yes".equals(str);
就不出空指针异常了!