没这样的写法吧?if(flag=request.getParameter("what"))--->
if(flag==request.getParameter("what"))
用.equals()比较好。if(flag.equals(request.getParameter("what")))
if(flag==request.getParameter("what"))
用.equals()比较好。if(flag.equals(request.getParameter("what")))
解决方案 »
- 在用struct2开发时,提示如下错误怎样解决呀?(好像是web.xml中的过滤器问题)
- myeclipse中内带的浏览器不见了
- MyEclipse7.0 M1下载+汉化+注册码(转载)
- 为什么我在java中向做好的jasper中不能填充起数据
- 该怎样为报表书写SQL查询语句???
- 请教多国语的<message-resources〉怎末写?
- hibernate创建1-N关联关系
- 恭请ECLIPSE高手进来,啼血求教eclipse写好的jsp放到哪才可运行
- weblogic 运行jsp问题
- 请教:有地方下载JRUN吗?或者其他类似的
- 如果一个公司的项目策划是业务员,那么程序员会怎样?
- 一个<html:form>的问题???
flag=request.getParameter("what")
if(flag!=null){
if(flag==xxxx){
.....
}
.....
}
if("true".equals(flag)){}
//参照上面这样就不会出现空指针异常了。
然后在比较是否相同if (request.getParameter("what") != null) {
if (flag.equals(request.getParameter("what"))) {
todo....
}
}
意思是flag的值是否等于request.getParameter("what")吗??
要是的话应该用equals()
"equals()" 判断值是否相等
"= ="判断地址是否相等
%><%
}
if(flag=request.getParameter("what")){
%>这两句肯定有问题,你是怎么判断的呢?取到what的参数给flag,是不是只要what不为空,就执行html代码,我觉得你这里的逻辑有问题,为空很多时候的错误很多时候是和逻辑有关系的!!自己再仔细看看
然后在比较是否相同这是最好的防止出错的方法,建议在写程序是尽量不要写
String s= request.getParameter("what");
if(s.equals("")|s=null);
{
...
}而应该
String s="";if (request.getParameter("what") != null)
s= request.getParameter("what");if (flag.equals(s))
{
...
}
if(request.getParameter("what")!=null){
...
...
试试看