`
taiwei.peng
  • 浏览: 227123 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

关于struts标签的用法注意事项

 
阅读更多
String hql=" from CTDepartment "; 
List list=evaluateservice.find(hql);
request.setAttribute("depList",list);
首先在action 里面查询全部的把它保存在一个作用域里面然后在页面上遍历
 <logic:iterate id="obj" name="depList"> 
          <html:option value="${obj.id}">${obj.name}</html:option>   
</logic:iterate>  
注意这里的id是随便起的名字,这里的name值是在action里面保存时起的名字。记住千万别搞错啦。
 
1.关于html标签的用法:
<html:select property="tbusievaluate.orgcode"> 
        <html:optionsCollection  label="name"  value="id" name="depList" />   
</html:select>    
注意这里的label 和value值是绑定在depList对象里面的值name属性是在action里面setAttribute里面的值.
2.
<html:optionsCollection property="headList" value="key" label="value"/>
这一种方式是绑定actionform 里面的值 headList 在form 里面有get 和set 方法。
3.
List xmlxlist = TfpjcUtil.getAllXmlx();        
request.setAttribute("xmlxlist", xmlxlist); 
 <html:select property="xmlx" styleId="xmlx">
       <html:option value="">----请选择----</html:option>
       <html:options collection="xmlxlist" labelProperty="cl_name" property="cl_id" /> 
 </html:select>
这种方法是在后台自己封装一个po 里面有两个字段 一个是cl_id 另一个是 cl_name
 
4.关于nested标签的用法
<html:form action="/qf/zbpz.TJ?method=insert" method="post">   
 <nested:nest property="tbusievaluate">
 <nested:text property="name" title="指标名称"/>
 <nested:textarea property="describe"/>
 <nested:select  property="evayear" styleId="year" />
</nested>
</html:form>
注意这里的styleId 相当于普通标签的id 属性 。
<nested:nest property="znTask" >
<nested:write property="taskname" />
</nested:nest>
c标签的用法
<c:if test="${obj[4]==0}">
<td class="center">
<input type="button" value="编辑指标" style="cursor: hand" onclick="edit('/qf/zbpz.TJ?method=edit&id=<bean:datapage name="obj" index="0"/>');"/> 
</td>
</c:if> 
struts标签头文件
<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tld/struts-nested.tld" prefix="nested" %>
JSTL标签头文件
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics