struts 标签嵌套

此文章为转载


struts标签是不能嵌套的,但是struts标签中可以嵌入java代码。 例一:<logic:iterate id="cl" name="Ids"> //循环取得id  
//比较beanname中的id是否和cl中的id相同,如果相同就显示cl 中的name                   <logic:equal name="beanname" property="id" value="<bean:write name="cl" property="id"/>">     
<bean:write name="cl" property="name"/>
</logic:equal>
</logic:iterate>          红色文字区就是错误的嵌套了,这样是得不到想要的结果的,可改为        <logic:iterate id="cl" name="Ids"> //循环取得id
<bean:define id="temId" name="cl" property="id" type="java.lang.String"/>              //比较beanname中的id是否和cl中的id相同,如果相同就显示cl中的name
<logic:equal name="beanname" property="id" value="<%=temId%>">     
<bean:write name="cl" property="name"/>
</logic:equal>
</logic:iterate>          这样先定义,后使用,就ok了。

例二:<html:submit value="<bean:message key="welcome.login" bundle="base"/>"/>
         应该为          <html:submit>
<bean:message key = "welcome.logon" bundle = "base"/>
</html:submit>


在页面第一次加载的时候,如何让其选择value="zh"的项?

<html:select property="language" onchange="submit();" value="zh">
<html:option value="en" key="global.lang.ENGLISH" />
<html:option value="zh" key="global.lang.SIMPLE_CHINESE" />  
</html:select>

猜你喜欢

转载自johndoe.iteye.com/blog/1513189
今日推荐