应该这样写吧:String Code1 = .....

解决方案 »

  1.   

    可以贴出你的程序
    我想问题不是出在这里的
    另外,Code1=null的写法是否有问题,请检查!
      

  2.   

    各位兄弟:程序贴出来了,希望实现的功能是输入产品代码,失去光标自动显示产品信息,输入数量后,自动计算总价,同时自动产生一个新的空行。各位大侠,帮帮忙吧,我没分了,多谢。
        
    <%@ page contentType="text/html;charset=gb2312"%>
    <jsp:useBean id="bean0" scope="session" class="TpEpms.ejb.OrderDetailClient" />
    <jsp:useBean id="person" scope="session" class="TpEpms.ejb.PersonalClient" />
    <jsp:useBean id="order" scope="session" class="TpEpms.ejb.OrdersClient" />
    <jsp:useBean id="cust" scope="session" class="TpEpms.ejb.CustomerClient" />
    <jsp:useBean id="product" scope="session" class="TpEpms.ejb.ProductClient" />
    <HTML>
    <style type="text/css">
    .title
    {FONT-SIZE:9pt;
     background-color: #CCCCFF;
     BORDER-RIGHT: #6B0029 1px solid;
     BORDER-TOP: #E677B9 1px solid;
     BORDER-LEFT: #E677B9 1px solid;
     BORDER-BOTTOM: #6B0029 1px solid;
     height: 18px;
     COLOR=#000000"
     <%--cursor: default;--%>
    }
    </style>
    <HEAD>
    <TITLE> add order</TITLE>
    </HEAD>
    <BODY>
    <H2><FONT size="5" color="#000099" face="新宋体"><TT><U>销售订单</U></TT></FONT></H2>
    <TABLE width="700" style="background-image : url(img/background.gif);">
    <TR>
    <TD width="88" height="8" style="FONT-SIZE:9pt;background-color: #CCCCFF; BORDER-RIGHT: #6B0029 1px solid; BORDER-TOP: #E677B9 1px solid; BORDER-LEFT: #E677B9 1px solid; BORDER-BOTTOM: #6B0029 1px solid;height: 18px; COLOR=#000000">订单日期</TD>
    <TD style="color: rgb(0,128,255); border-left: medium none; border-right: medium none; border-top: medium none; border-bottom: 1pt solid rgb(5,5,5)" align="center" width="146">
    <script language="JavaScript">
    today=new Date();
    function initArray(){
    this.length=initArray.arguments.length
    for(var i=0;i<this.length;i++)
    this[i+1]=initArray.arguments[i]  }
    document.write("<font color=blue>",today.getYear(),"<font color=blue>年","<font color=blue>",today.getMonth()+1,"<font color=blue>月","<font color=blue>",today.getDate(),"<font color=blue>日 </FONT>"," ");</script></TD>
    <TD width="68" height="8" style="FONT-SIZE:9pt;background-color: #CCCCFF; BORDER-RIGHT: #6B0029 1px solid; BORDER-TOP: #E677B9 1px solid; BORDER-LEFT: #E677B9 1px solid; BORDER-BOTTOM: #6B0029 1px solid;height: 18px; COLOR=#000000">订单编号</TD>
    <TD width="191"><INPUT TYPE="text" size="20" NAME="" value="" style="color: rgb(24,9,255); border-left: medium none; border-right: medium none; border-top: medium none; border-bottom: 1pt solid rgb(5,5,5)"></TD>
    </TR>
    <TR>
    <TD width="88" height="8" style="FONT-SIZE:9pt;background-color: #CCCCFF; BORDER-RIGHT: #6B0029 1px solid; BORDER-TOP: #E677B9 1px solid; BORDER-LEFT: #E677B9 1px solid; BORDER-BOTTOM: #6B0029 1px solid;height: 18px; COLOR=#000000">客户编号</TD>
    <TD width="146"><INPUT TYPE="text" size="20" NAME="" style="color: rgb(24,9,255); border-left: medium none; border-right: medium none; border-top: medium none; border-bottom: 1pt solid rgb(5,5,5)"></TD> <TD width="68" height="8" style="FONT-SIZE:9pt;background-color: #CCCCFF; BORDER-RIGHT: #6B0029 1px solid; BORDER-TOP: #E677B9 1px solid; BORDER-LEFT: #E677B9 1px solid; BORDER-BOTTOM: #6B0029 1px solid;height: 18px; COLOR=#000000">销售员</TD>
    <TD width="191"><INPUT TYPE="text" size="20" NAME="" style="color: rgb(24,9,255); border-left: medium none; border-right: medium none; border-top: medium none; border-bottom: 1pt solid rgb(5,5,5)"> </TD>
    </TR>
    </TABLE>
    <%
    int num,i;
      num=(new Integer(request.getParameter("itemNum").toString())).intValue();
      num++;
    %>
    <form action="orderadd.jsp" method="post" id="add">
    <input type="hidden" id="itemNum" name="itemNum" value="<%=num%>">
    <div class="title" align="left" nowrap="true">
      <TABLE border="0" cellspacing="1" cellpadding="1" width="80%">
        <tr>
          <Th  height="8" width="70">商品编号</Th>
          <Th  height="8" width="70">商品名称</Th>
          <Th  width="70" height="8">商品单价</Th>
          <Th  width="70" height="8">数量</Th>
          <Th  width="70" height="8">金额</Th>
       </tr>
    <%
    String Code1;
    String Code2;
    String Num1;for(i=0;i<(num-1);i++){
    Num1 = "proNum" + ((new Integer(i)).toString());
    Code2 = "proCode" + ((new Integer(i)).toString());
    Code1=request.getParameter(Code2);
    product.findByPrimaryKey(Code1);
    %>
    <tr>
       <td align=center width="70"><input size=10 type="text" id="proCode<%=i%>" name="proCode<%=i%>"  value=<%=product.getSProdCode()%> onblur="isValid(form)"> </td>
       <td align=center width="70" size=10><%=product.getSProdName()%></td>
       <td align=center width="70"><%=product.getMProdPrice()%></td>
       <td align=center width="70"><input size=10 type="text" id="proNum<%=i%>" name="proNum<%=i%>" value="<%=request.getParameter(Num1)%>" onblur="isValid1(form)"> </td>
       <td align=center width="70"><%=product.getMProdPrice()%>*<%=request.getParameter(Num1)%></td>
    </tr>
    <%}
    if(!(Code1=null)){
    %>
    <tr>
       <td align=center width="70"><input size=10 type="text" id="proCode<%=i%>" name="proCode<%=i%>" onblur="isValid(form)"> </td>
       <td align=center width="70"></td>
       <td align=center width="70"></td>
       <td align=center width="70"><input size=10 type="text" id="proNum<%=i%>" name="proNum<%=i%>" onblur="isValid1(form)"> </td>
       <td align=center width="70"></td>
    </tr>
    <%}%>
    </TABLE>
    </DIV>
    </form>
    </BODY>
    </HTML>
    <script language="javascript">
    function isValid(form)
      {
      if(form.proCode<%=i%>.value==""){
      alert("don't null!");
      return false;}  add.submit();
     }
     function isValid1(form)
     {
     if(form.proNum<%=i%>.value==""){
      alert("please input quantity or no this product!");
      return false;}
      if(form.proNum<%=i%>.value=="0"){
      alert("please input quantity or no this product!");
      return false;}
      add.submit();
     }
    </script>
      

  3.   

    if (!(code1 == null)) {
      

  4.   


    1、 you may define the argument like this: String Code1 = null;2、 why not write the selection sentence like this : if(Code1 != null) ?
      

  5.   

    if (!(code1 == null)) {
      

  6.   

    黄黄说的对,要先把eode1初试化! : String Code1 = null
      

  7.   

    agree with hyhong_h(黄黄) 
      

  8.   

    agree with hyhong_h(黄黄)