jquery+struts页面组合

来源:互联网 发布:淘宝弹弓钢珠批发 编辑:程序博客网 时间:2024/05/29 18:23

项目中需求在一个界面中显示全部数据,部分数据(根据条件来),如果没有用到jquery的话,请不要往下继续看,实现起来也很简单,就是静态页面多点,每个条件对应于一个静态页面.

如果用到jquery的话 没有分页操作的话 也很简单.如果你用到分页的话 那么同一个jsp页面怎么跳转了(条件不同,有可能会乱掉).也有人会说,根据参数判断了,对了就是这么简单.

废话少说直接上代码:

最终的展示效果如果下:

由于项目设计到商业问题 所以暂时这个样子 能说明问题就行. 进入主界面之后默认是 查询全部记录  上面有根据账号查询,时间查询,数据展示不难,有点困难的是分页之后 点击链接跳转的问题 弄不好的话 3个会整合在一起,数据容易出错.

那么我们也用最容易实现的办法 回传给前段的数据中 新增一个标记位:

    request.setAttribute("mark", "bytime"); //这个标记就是说明数据查询方式 是按照时间查询的.

在前端处理的情况下 我们根据标记 做响应的链接跳转处理

代码如下:

<s:if test="#request.mark == 'byaccount'">
                <tr class="trfoot">
                    <td colspan="7" align="right">
                    [<a
                        href="moneyTypeAction-zhangdanAccount.action?pageNow=1&accountname=<s:property value="#request.accountname"/>">首页</a>] [<a
                        href="moneyTypeAction-zhangdanAccount.action?pageNow=<s:property value="#request.pageNow-1" />&accountname=<s:property value="#request.accountname"/>">上一页</a>]
                        [<a
                        href="moneyTypeAction-zhangdanAccount.action?pageNow=<s:property value="#request.pageNow+1" />&accountname=<s:property value="#request.accountname"/>">下一页</a>]
                        [<a
                        href="moneyTypeAction-zhangdanAccount.action?pageNow=<s:property value="#request.maxPage" />&accountname=<s:property value="#request.accountname"/>">尾页</a>]
                        当前第<a href="" style="text-decoration: none"><s:property
                                value="#request.pageNow" /> /<s:property
                                value="#request.maxPage" /></a>页</td>
                   </tr>
               </s:if>
               <s:elseif test="#request.mark == 'bytime'">
                <tr class="trfoot">
                    <td colspan="7" align="right">
                    [<a
                        href="moneyTypeAction-zhuanzhangByTime.action?pageNow=1&startTime=<s:property value="#request.startTime"/>&endTime=<s:property value="#request.endtime"/>">首页</a>] [<a
                        href="moneyTypeAction-zhuanzhangByTime.action?pageNow=<s:property value="#request.pageNow-1" />&startTime=<s:property value="#request.startTime"/>&endTime=<s:property value="#request.endtime"/>">上一页</a>]
                        [<a
                        href="moneyTypeAction-zhuanzhangByTime.action?pageNow=<s:property value="#request.pageNow+1" />&startTime=<s:property value="#request.startTime"/>&endTime=<s:property value="#request.endtime"/>">下一页</a>]
                        [<a
                        href="moneyTypeAction-zhuanzhangByTime.action?pageNow=<s:property value="#request.maxPage" />&startTime=<s:property value="#request.startTime"/>&endTime=<s:property value="#request.endtime"/>">尾页</a>]
                        当前第<a href="" style="text-decoration: none"><s:property
                                value="#request.pageNow" /> /<s:property
                                value="#request.maxPage" /></a>页</td>
                   </tr>
               </s:elseif>
               <s:else>
               <tr class="trfoot">
                    <td colspan="7" align="right">
                    [<a
                        href="moneyTypeAction-userzhuanzhang.action?pageNow=1">首页</a>] [<a
                        href="moneyTypeAction-userzhuanzhang.action?pageNow=<s:property value="#request.pageNow-1" />">上一页</a>]
                        [<a
                        href="moneyTypeAction-userzhuanzhang.action?pageNow=<s:property value="#request.pageNow+1" />">下一页</a>]
                        [<a
                        href="moneyTypeAction-userzhuanzhang.action?pageNow=<s:property value="#request.maxPage" />">尾页</a>]
                        当前第<a href="" style="text-decoration: none"><s:property
                                value="#request.pageNow" /> /<s:property
                                value="#request.maxPage" /></a>页</td>
                   </tr>
                   
               </s:else>


中间的显示部分根据查询条件的不同 做处理就行.



0 0
原创粉丝点击