a.jsp(html代码略,只写关键的)
<%@ page contentType="text/html; charset=GB2312"%>
<%
request.setCharacterEncoding("gb2312");//这句有没有效果一样,试过了,我传的是英文字母和数字。
String errorInfo=request.getParameter("errid");
if(errorInfo=="1001")
{errorInfo="用户名或密码错误,请重新输入!";}
else
   {errorInfo="";}
%>
b.jsp:
<%@ page contentType="text/html; charset=GB2312"%>
<%
String errid;
errid="1001";
response.sendRedirect("a.jsp?errid="+errid);
response.sendRedirect("a.jsp?errid='"+errid+"'");//这句替换上面出现同样情况
%>
a.jsp是登录页面,具体验证在b.jsp中(已略去,确定没问题),然后我返回。问题是:在a.jsp中,这样的比较竟然不是真,最后 errorInfo="",请问这是为什么?怎么解决?谢谢谢谢!!!

解决方案 »

  1.   

    小弟初写JSP,项目又紧,加班到0点几天了,唉,DX帮个忙吧。谢谢了,我先去买个早点5555~~
      

  2.   

    a.jsp(html代码略,只写关键的)
    <%@ page contentType="text/html; charset=GB2312"%>
    <%
    request.setCharacterEncoding("gb2312");//这句有没有效果一样,试过了,我传的是英文字母和数字。
    String errorInfo=request.getParameter("errid");
    if(errorInfo.compareTo("1001")==0)//这儿修改一下  看行了不
    {errorInfo="用户名或密码错误,请重新输入!";}
    else
       {errorInfo="";}
    %>
      

  3.   

    看浏览器中有没有值
    你在a.jsp中 直接打印errorInfo 看能不能打印出来
      

  4.   

    http://58.34.149.87:8080/oqxgl/login.jsp
    就是这个地址。。a.jsp=login.jsp b.jsp=check.jsp左上角para=是打印结果。要点击登录后才会出现。
      

  5.   

    把你的a.jsp的IF改成
    <%
    String errorInfo=request.getParameter("errid");
    System.out.println(errorInfo);
    if(errorInfo=="1001" ||errorInfo.equals("1001"))
    {errorInfo="用户名或密码错误,请重新输入!";}
    else
       {errorInfo="";}
    System.out.println(errorInfo);
    %>
    这样就可以了,希望对你有帮助
      

  6.   

    "=="在String表示两个引用是否引用同一个对象
    equals()在String中表示判断内容是否相同