哥哥姐姐们我的查询需要根据开始时间和结束时间来查询,我不会写啊,不知道咋办了
jsp
<table width="400" height="150">
<tr>
<td>开始日期</td>
<td><input type="text" style="width: 70px"
onfocus="HS_setDate(this)"></td>
</tr>
<tr>
<td>结束日期</td>
<td><input type="text" style="width: 70px"
onfocus="HS_setDate(this)"></td>
</tr>
<tr>
<td><a href='<s:url action="search"/>'>查询</a></td>
</tr>
</table>
<table align="center" width="70%" border="1" bordercolor="black">
<tr>
<td width="10%" align="center">日期时间</td>
<td width="8%" align="center">操作员</td>
<td width="15%" align="center">IP地址</td>
<td width="10%" align="center">模块</td>
<td width="15%" align="center">动作</td>
<td width="20%" align="center">结果</td>
<td width="22%" align="center">备注信息</td>
</tr>
<s:iterator value="logs">
<tr>
<td><s:property value="datetime" /></td>
<td><s:property value="operatorId" /></td>
<td><s:property value="clientIp" /></td>
<td><s:property value="moduleName" /></td>
<td><s:property value="action" /></td>
<td><s:property value="status" /></td>
<td><s:property value="message" /></td>
</tr>
</s:iterator>
</table>
jsp这样写行么?action里该怎么做啊

解决方案 »

  1.   

    select * from 表 where 日期 between 开始日期 and 结束日期
      

  2.   

    用HIBERNATE最好,因为有反向工程.在反向工程DAO里面改方法,然后在ACTION里面去调用,就行了..
      

  3.   

    用得是ssh
    我在action里调用,可是不行啊,我就调接口里的findSystemLogs(a,b);里面的两个参数是开始时间和结束时间
      

  4.   

    那你有没有在spring配制文件中添加依赖注入?
      

  5.   

    有添加啊,没有异常啊,开始时间和结束时间怎么才能得到啊?我得到都是‘null’
      

  6.   

    你可以为这两个文本框各取上一个name="值";然后在action方法里用String begin=request.getParameter("name值").toString();就可以获得了。
      

  7.   

    你的页面要加字段的name
    <table width="400" height="150"> 
    <tr> 
    <td>开始日期 </td> 
    <td> <input type="text" style="width: 70px"  name="sDate"
    onfocus="HS_setDate(this)"> </td> 
    </tr> 
    <tr> 
    <td>结束日期 </td> 
    <td> <input type="text" style="width: 70px"  name="eDate" 
    onfocus="HS_setDate(this)"> </td> 
    </tr> 
    <tr> 
    <td> <a href=' <s:url action="search"/>'>查询 </a> </td> 
    </tr> 
    </table> 
    后台用:
    String sDate=request.getParameter("sDate");
    String eDate=request.getParameter("eDate");
      

  8.   

    我就是这样加的啊 
    <table width="400" height="150">
    <tr>
    <td>开始日期</td>
    <td><input type="text" style="width:70px" name="starttime" onfocus="HS_setDate(this)"></td>
    </tr>
    <tr>
    <td>结束日期</td>
    <td><input type="text" style="width:70px" name="endtime" onfocus="HS_setDate(this)"></td>
    </tr>
    <tr>
    <td><a href='javascript:void(0)' onClick="time('${starttime}')">查询</a></td>
    </tr>
    </table>
    <table align="center" width="70%" border="1" bordercolor="black">
    <tr>后台这样写的
    public String search()throws Exception{
         String st = request.getParameter("starttime");
         String et = request.getParameter("endtime");
         System.out.println(st);
         System.out.println(et);
         if(st != null && et != null){打印的都是 null  啊 
      

  9.   

    当前的页面的提交方式,是get还是post?
      

  10.   

    后台直接取啊,然后放list或map里面
      

  11.   

    <%@ taglib prefix="sx" uri="/struts-dojo-tags"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>首页</title>
    <sx:head />
    </head>
    <body>
    <s:form action="findAllChild" namespace="/child">
    <sx:datetimepicker name="starttime"/>
            <sx:datetimepicker name="endtime"/>
    <s:submit value="submit" />
    </s:form> Query query= session.createQuery("from tableName where stime between ? and ? ");
           query.setDate(0, starttime);
           query.setDate(1, endtime);
    需要引入包struts2-dojo-plugin-2.1.6.jar具体的datetimepicker 使用方法可以看struts2带的showcase/web/tag/ui/timepicker 
      

  12.   

    补充下,starttime,endtime在action中定义为Date类型。并有get/set方法