简单CMS项目笔记之五:struts标签前台显示



这个是jsp输出的页头,之前没怎么研究过显示的细节,今儿好好读读,其中:


<s2:set name="types" value="#session.typeMap"/>    把session中的typeMap取出来,在本页面起个别名叫“types”

<s2:if test="#types==null||#types.size()==0"> 没有信息类别可显示!</s2:if>  检查取出的Map里是否有值

<a href="goindex.action" style="color:white">首&nbsp;&nbsp;&nbsp;&nbsp;页</a></font></td>  首页的action,不只是连接

<s2:iterator status="typesStatus" value="types">   status是iterator的可选参数,这利用它做标记,完成循环( <s2:if test="#typesStatus.index==4"></tr><tr align="center"></s2:if>检查是否等于4)


<a href="info_ListShow.action?infoType=<s2:property value='key'/>" style="color:white"><s2:property value="value"/></a>这个连接是重点,

<s2:property value='key'/>和<s2:property value="value"/>不是要显示名为:“key”和“value”的值,而是要显示这个iterator中的遍历的Map的“键-值”对

"info_ListShow.action?infoType=<s2:property value='key'这句是超链接的地址,这个地址也不是原来看见的绝对地址,而是用遍历出来的“名(键)”作为参数,组装进action语句,这样就把遍历出来的编号(代表信息类别)传到action中,再去底层查表

<s2:property value="value"/></a> 只是显示超链接的字面,Map中value是信息类别的名称,key是该类别的编号。



<body>
    <center>
        <table border="0" width="100%" cellspacing="0" cellpadding="0">
            <!-- 顶部菜单 -->
            <tr height="20">
                <td style="text-indent:10" valign="bottom">
                    <a href="info_Add.action?addType=linkTo" style="color:gray">[发布信息]</a>
                    <a href="log_isLogin.action" style="color:gray">[进入后台]</a>
                </td>
                <td align="right" valign="bottom">
                    <a href="#"  style="color:gray" οnclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://localhost:8080/CityInfo');">设为主页 -</a>
                    <a href="javascript:window.external.AddFavorite('http://localhost:8080/CityInfo','都市供求信息网')" style="color:gray">收藏本页 -</a>
                    <a href="mailto:123@***.com.cn" style="color:gray">联系我们</a>
                     
                </td>
            </tr>
            <!-- 导航菜单 -->
            <tr height="56">
                <td align="center" width="220" background="images/logo.gif"></td>
                <td align="right" background="images/menu.gif">
                    <s2:set name="types" value="#session.typeMap"/>
                    <s2:if test="#types==null||#types.size()==0">没有信息类别可显示!</s2:if>
                    <s2:else>
                        <table border="0" width="600">
                            <tr align="center">
                                <td width="100"><a href="goindex.action" style="color:white">首    页</a></font></td>
								<!-- status是保证够4个,就换行一次 -->
                                <s2:iterator status="typesStatus" value="types">
                                    <td width="100"><a href="info_ListShow.action?infoType=<s2:property value='key'/>" style="color:white"><s2:property value="value"/></a></td>
                                    <s2:if test="#typesStatus.index==4"></tr><tr align="center"></s2:if>
                                </s2:iterator>
                            </tr>                      
                        </table>
                    </s2:else>
                </td>
            </tr>
        </table>
        <table border="0" width="100%" height="90" cellspacing="0" cellpadding="0" style="margin-top:1">
            <tr><td align="center"><img src="images/pcard1.jpg"></td></tr>
        </table>
    </center>
</body>



















  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值