<html:form  action="/entryAction.do?action=search&search=search&expression=NULL"  method="post">
      请输入要查找的 设备编号 : <html:text property="设备编号" />
      <html:submit value="查找" />
      <html:reset value="重写" />
  </html:form>
<html:form action="entryAction.do?action=search&expression=NULL" method="post">
      <html:submit value="全部显示" />
  </html:form>
</body>
</html:html>
这是表单提交的代码
这是逻辑处理的类
package  emptyprj;
……
///////////////查找数据库
       //<sqlstr>
       String sql="SELECT * FROM dbo.入库表";
       //</sqlstr>              ////SQL字符处理
       if("search".equals(search))
       {
           //<search>
              sql+=" where ";
                     sql+="设备编号";
                     sql+="='";
                     if("NULL".equals(expression)||"".equals(expression))
                    {
                  sql+=m_entryForm .get设备编号();
              }
              else
              {
                  sql+=expression;
              }
              
              sql+="'";
           //</search>
       }             //<分页>
        m_entryDAO.setLength(10);//设置每页显示记录数
        int ipage;//当前页
        try 
        {
            String page=request.getParameter("page");//分页参数,读取请求的当前页
            ipage=java.lang.Integer.parseInt(page,10);
        }
        catch (Exception e) 
             {
                 ipage=m_entryForm.getPage();
             } 
             if(ipage<1)ipage=1;
             Collection col = m_entryDAO.findSQL(sql,ipage);//通过DAO对象查询数据
        request.setAttribute("entry",col);  //保存数据
       
        String pagestr=m_entryDAO.getPagestr(ipage);//分页字符串,分页内容
              if(!"search".equals(search))    //查找和全部显示两个不同的操作,其分页字符串不同,在此进行处理。如果是全部显示则去掉"search=search&"
       {
           pagestr=pagestr.replaceAll("search=search&","");
       }
        m_entryForm.setPagestr(pagestr);   
              m_entryForm.setAction(action);  
        request.setAttribute("entryForm",m_entryForm);
              //</分页>
       return mapping.findForward("success");
    } 
catch (SQLException e) 
        {
       e.printStackTrace();
       throw new RuntimeException("Unable to get connection.");
     } 
        finally
        {
           try 
             {
         if (con != null)
           con.close();
            } 
             catch (SQLException e) 
             {
         throw new RuntimeException(e.getMessage());
            }
       }    }
……

解决方案 »

  1.   

    把tld文件也贴上来看哈子啊,这才是最重要的撒
      

  2.   

    sql+=m_entryForm .get设备编号();
      

  3.   

    天啊,为什么不用DispatchAction,而用Action呢?
    这么都的if。
      

  4.   

    这里面的值是怎么传递的,如果我想实现一个申请时间或者按其它方式查找,要怎么提交表单和怎么在逻辑类里写SQL语句
    -------------〉
    1,一个<input type="text" name="tiaojian"/>是查询条件的前台输入,<input type="submit"(or button) name="提交" >提交按钮,提交,传值,可以表单(<form></form>)传值, 也可以?传值,如action=*.jsp?id="1",后台用request.getParameter("tiaojian")来获得前台数据,也可以form.get("tiaojian"),像struts
    2,sql="select 列名 form 表名 where 条件"