下拉列表中未显示值

时间:2018-01-18 11:13:51

标签: java spring

我的网络应用程序中存在一个问题,我为整个应用程序编写了以下代码,它工作正常......但不是在这种情况下。 我在JSTL中使用了正确的变量名称,我的查询运行正常并产生了我想要的所需结果,但仍然没有出现在下拉列表中..我甚至无法弄清楚

任何人都可以帮我理清这个

<td>
    <span id="store_${i}"></span>
    <f:select class="form-control"  path="boqList[${i}].organizationCode" id="storeId${i}"                                      onchange="chekeAvailibiltyAtStore(this.value,'${b.itemCode}','${b.itemUnit}','${i}')" required="true"> 
        <f:option value="">Select Area Store</f:option>
        <c:forEach  items="${areaStors}" var="as" >
            <f:option value="${as.organizationCode}">${as.organizationName}</f:option>
        </c:forEach>
    </f:select>
</td>

内部控制器

mav.addObject("areaStors", areaStoreDAO.findAll());

内部服务(查询工作正常)

 public List<ErpAreaStore> findAll() {
        String query = "SELECT  ORGANIZATION_CODE "
                + "           , ORGANIZATION_NAME "
                + "  FROM XXAP_AREA_STORE "
                + "  ORDER BY ORGANIZATION_CODE ASC ";
        MapSqlParameterSource param = new MapSqlParameterSource();
        List<ErpAreaStore> inventoryOnhands = getNamedParameterJdbcTemplate().query(query, param, new RowMapper<ErpAreaStore>() {
            @Override
            public ErpAreaStore mapRow(ResultSet rs, int rowNo) throws SQLException {
                ErpAreaStore areaStore = new ErpAreaStore();
                areaStore.setOrganizationCode(rs.getInt("ORGANIZATION_CODE"));
                areaStore.setOrganizationName(rs.getString("ORGANIZATION_NAME"));
                return areaStore;
            }
        });
        return inventoryOnhands;
    }

POJO

public class ErpAreaStore implements java.io.Serializable {

    private int organizationCode;
    private String organizationName;

    public int getOrganizationCode() {
        return organizationCode;
    }

    public void setOrganizationCode(int organizationCode) {
        this.organizationCode = organizationCode;
    }

    public String getOrganizationName() {
        return organizationName;
    }

    public void setOrganizationName(String organizationName) {
        this.organizationName = organizationName;
    }

}

见下面的截图

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:1)

在JSP的开头添加<jsp:useBean> tag。这是areaStors列表存在的直接测试。例如:

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="f" uri="http://www.springframework.org/tags/form" %>

<jsp:useBean id="areaStors" scope="request" type="java.util.List"/>

    <!-- ... -->
    <td>
        <span id="store_${i}"></span>
        <f:select class="form-control"  path="boqList[${i}].organizationCode" id="storeId${i}" onchange="chekeAvailibiltyAtStore(this.value,'${b.itemCode}','${b.itemUnit}','${i}')" required="true"> 
            <f:option value="">Select Area Store</f:option>
            <c:forEach  items="${areaStors}" var="as" >
                <f:option value="${as.organizationCode}">${as.organizationName}</f:option>
            </c:forEach>
        </f:select>
    </td>