struts2的常用标签

<s:url action="helloworld_add" namespace="/test"><s:param name="psersonid" value="23"/></s:url>
生成类似如下路径:
/struts/test/helloworld_add.action?personid=23

 

当标签的属性值作为字符串类型处理时,%符号的用途是计算OGNL表达式的值。
  <s:set name="myurl" value="http://www.sina.com"/>
   <s:url value="#myurl"/><br>
   <s:url value="%{#myurl}"/>
输出结果: #myurl
            http://www.sina.com

%{}就是明确告诉程序这就是ognl表达式

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

 

****表单标签_checkboxxlist复选框
如果集合为list
 <s:checkboxlist name="list" list="{"java","net","ror","php"}"  value="{"java","net"}"/>

 

运行后的代码:

<input type="checkbox" name="list" value="java" id="list-1" checked="checked"/>
<label for="list-1" class="checkboxLabel">java</label>
<input type="checkbox" name="list" value="c++" id="list-2"/>
<label for="list-2" class="checkboxLabel">c++</label>
<input type="checkbox" name="list" value=".net" id="list-3" checked="checked"/>
<label for="list-3" class="checkboxLabel">.net</label>
<input type="checkbox" name="list" value="opengl" id="list-4"/>
<label for="list-4" class="checkboxLabel">opengl</label>
<input type="hidden" id="__multiselect_list" name="__multiselect_list" value="" /> 

 

如果集合为map

<s:checkboxlist name="map" list="#{1:'java',2:'c++',3:'.net',4:'opengl'}" listKey="key" listValue="value" value="{1,2,3}"/>
       <input type="checkbox" name="map" value="1" id="map-1" checked="checked"/>
<label for="map-1" class="checkboxLabel">java</label>
<input type="checkbox" name="map" value="2" id="map-2" checked="checked"/>
<label for="map-2" class="checkboxLabel">c++</label>
<input type="checkbox" name="map" value="3" id="map-3" checked="checked"/>
<label for="map-3" class="checkboxLabel">.net</label>
<input type="checkbox" name="map" value="4" id="map-4"/>
<label for="map-4" class="checkboxLabel">opengl</label>
<input type="hidden" id="__multiselect_map" name="__multiselect_map" value="" /> 

 

 

里面有很多不需要的标签 为了去掉这些struts自动生成乱七八糟的标签 需要

 <!-- 默认的视图主题
    <constant name="struts.ui.theme" value="simple" />设计这样。。就ok了

 

 

 

表单标签radio单选框
该标签的使用和checkboxlist复选框相同
如果该集合里存放的是javabean(psersonid和name为person的属性)
<s:radio name="beans" list="#request.persons" listKey="psersonid" listValue="name"/>

 

 

 

 

 

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值