从控制层传三个及以上不同类型的值到页面

方法一:封装成一个临时实体类。

方法二:将这些值用json(JSONObject)转换成字符串形式,然后在通过json(JSON.parse)转换成Map,放入Map或List集合中。

例:1.控制层

Map<String,Map<String,String>> maps=new
HashMap<String,Map<String,String>>();
for (CoinProps newCoins : digtalCoinsNew) {
	boolean isFixedTimeLimit = limitService.isLimitCoinType(newCoins);
	String coinName = newCoins.getEnname();
	if ( isFixedTimeLimit ){
		fixedTimeLimitCoins.append(fixedTimeLimitCoins.length() > 0 ? "," : "").append(coinName);
	}
	UserWithdrawLimit uwl = uwlDao.getByUser(userId, newCoins);
	JSONObject json = new JSONObject();
	json.put("name", coinName);
	json.put("timeLimit", isFixedTimeLimit);
	json.put("withdrawLimit", uwl);
	String string = json.toString();
	Map map=(Map)com.alibaba.fastjson.JSON.parse(string);
	maps.put(coinName, map);
}

  2.页面

<c:forEach items="${limit }" var="limit">
<c:if test="${ !limit.value.timeLimit }">
      <span class="s2">
          ${limit.value.name }单笔限额:<em class="green"><fmt:formatNumber value="${limit.value.withdrawLimit.everyTimeAmount}" pattern="#.##"/></em>
          <a href="javascript:dayCashNew('${user.id}','everyTimeAmount','${limit.value.name }','${limit.value.withdrawLimit.userId}')"> 修改</a>
      </span>
      <span class="s2">
          ${limit.value.name }单日限额:<em class="green"><fmt:formatNumber value="${limit.value.withdrawLimit.everyDayAmount}" pattern="#.##"/></em>
          <a href="javascript:dayCashNew('${user.id}','everyDayAmount','${limit.value.name }','${limit.value.withdrawLimit.userId}')"> 修改</a>
        </span>
</c:if>
</c:forEach>

  3.附

@Entity
public class UserWithdrawLimit extends StrBaseLongIdEntity {

    private static final long serialVersionUID = -2386115543279873656L;
    /**当为0时,表示默认全局设置*/
    private int userId;
    /**币种类型,参见CoinProps的fundsType*/
    private int fundsType;
    /**单笔提现额度*/
    private String everyTimeAmount;
    /**单日提现额度*/
    private String everyDayAmount;
    /**单日免审提币额度*/
    private String dayFreeCash;
   
    public UserWithdrawLimit() {
    }

    public UserWithdrawLimit(Datastore ds) {
        super(ds);
    }
  
    .........

  

原文地址:https://www.cnblogs.com/heinight/p/7373695.html