日期:2014-05-16  浏览次数:20541 次

<html:select><html:optionsCollection>中怎么取得数据库中对应值?
[/color]我在jsp页面中用了:
<html:select property="custLevelLabel" value="${customer.custLevelLabel}" size="1">
<html:optionsCollection name="level" label="dictItem" value="dictId"/>
</html:select>
用于取得数据库中数据库中数据,这点已经实现,已经把一列值取出并放入下拉列表。
这是一个编辑页面,也就是从一个列表页面跳转到这个页面(编辑页面代码如下):
<%@ page language="java" pageEncoding="UTF-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
<head>
<html:base />

<title>客户信息</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

<script type="text/javascript" src="../../../scripts/js/common.js"></script>
<link rel="stylesheet" href="../../../styles/css/style.css" type="text/css"></link>
<script type="text/javascript">
function showMessage(){
var msg=document.getElementById("lnkmsg").value;
showMsg(msg);
}
</script>
</head>

<body onload="showMessage();">
<div class="page_title">客户信息管理 > 客户信息</div>
<html:form action="/updatecustomer.do?id=${custId}" method="post">
<div class="button_bar">
<html:button property="" styleClass="common_button" onclick="help('');">帮助</html:button>
<html:button property="" styleClass="common_button" onclick="to('linkman.do?id=${custId}');">联系人</html:button>
<html:button property="" styleClass="common_button" onclick="to('activity.do?id=${custId}');">交往记录</html:button>
<html:button property="" styleClass="common_button" onclick="to('orders.do?id=${custId}');">历史订单</html:button>
<html:button property="" styleClass="common_button" onclick="back();">返回</html:button>
<html:submit property="submit" styleClass="common_button">保存</html:submit>
</div>
<logic:present name="customer">
<table class="query_form_table">
<tr>
<th>客户编号</th>
<td>${customer.custNo}</td>
<th>名称</th>
<td><html:text property="custName" value="${customer.custName}"></html:text><span class="red_star"></span></td>
</tr>
<tr>
<th>地区</th>
<td>
<html:select property="custRegion" value="${customer.custRegion}">
<html:optionsCollection name="region" label="dictItem" value="dictId"/>
</html:select>
<th>客户经理</th>
<td>
<html:select property="custManagerName" value="${customer.custManagerName}" size="1">
<html:optionsCollection name="mamager" label="usrName" value="usrId"/>
</html:select>
</td>
</tr>
<tr>
<th>客户等级</th>
<td>
<html:select property="custLevelLabel" value="${customer.custLevelLabel}" size="1">
<html:optionsCollection name="level" label="dictItem" value="dictId"/>
</html:select>