java类中定义了一个LabelValueBean
public final static LabelValueBean[] SELECT_CONSTANT1 = new LabelValueBean[] {
new LabelValueBean("红", "R"), new LabelValueBean("绿", "G"),
new LabelValueBean("蓝", "B") };
在struts中通过标签显示这些值没有问题,选中某个值后保持到数据库中,数据库中保存的是"R"之类的,如何显示出“红”来呢?
小弟刚学struts,多帮忙啊!!!!!!!
public final static LabelValueBean[] SELECT_CONSTANT1 = new LabelValueBean[] {
new LabelValueBean("红", "R"), new LabelValueBean("绿", "G"),
new LabelValueBean("蓝", "B") };
在struts中通过标签显示这些值没有问题,选中某个值后保持到数据库中,数据库中保存的是"R"之类的,如何显示出“红”来呢?
小弟刚学struts,多帮忙啊!!!!!!!
顯示紅么就把紅放到r的位置上呀
new LabelValueBean("红", "紅"),
===================================
還是你又要紅又要r?
那就後面都賦下值
new LabelValueBean("红", "紅 R"),
或者寫個2維數組好了
我的表示层中通过下拉选中值保存到数据库 是以"R""G""B"的形式啊
取出来如何对应显示出红绿蓝呢???
不要通过if判断哦
我的意思是 label和value 在数据库和页面之间如何转换,写个转换的类吗??
<logic:equal value="G" property="color">绿</logic:equal>
<logic:equal value="B" property="color">蓝</logic:equal>我想你说的是这个意思,我一般都这么做...JF
你可以建一个bean,属性是value和label(R,"红")
把多个bean放在list里面,不要放数组里
页面上可以写成
<html:select name="XXXForm" property="XXXCode">
<html:options collection="colorList" property="value" labelProperty="label"/>
</html:select>