Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/344.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用SPRING在JSP中生成下拉框_Java_Spring_Jsp_Model View Controller - Fatal编程技术网

Java 使用SPRING在JSP中生成下拉框

Java 使用SPRING在JSP中生成下拉框,java,spring,jsp,model-view-controller,Java,Spring,Jsp,Model View Controller,你好。 我有一个JSP视图和一个控制器,它为它提供了一个要填充的模型。 这是我的控制器用于JSP的方法 @RequestMapping("/seller") public ModelAndView seller() { if(isUserInRole("SELLER_ROLE")) { List<SellerStatistics> entities = sellerService.getAllStatistics().getContent();

你好。 我有一个JSP视图和一个控制器,它为它提供了一个要填充的模型。 这是我的控制器用于JSP的方法

@RequestMapping("/seller")
public ModelAndView seller() {
    if(isUserInRole("SELLER_ROLE"))
    {
        List<SellerStatistics> entities = sellerService.getAllStatistics().getContent();
        List<String> statuses = sellerService.getStatuses();
        Map<String, Object> model = new HashMap<String, Object>();
        model.put("gridRows", entities);
        model.put("statuses", statuses);
        return new ModelAndView("seller",model);
    }
    return new ModelAndView("login");
}
@RequestMapping(“/seller”)
公共模型和视图卖方(){
if(iUserInRole(“卖方角色”))
{
列表实体=sellerService.getAllStatistics().getContent();
列表状态=sellerService.getStatuses();
映射模型=新的HashMap();
模型放置(“网格”,实体);
模型放置(“状态”,状态);
返回新模型和视图(“卖方”,模型);
}
返回新的ModelAndView(“登录”);
}
网格行包含必须插入JSP表中的信息。该表中的一列是“状态”。状态必须是下拉框才能更改此行的状态

这是我的JSP:

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ include file="header.jsp" %>
<div class="container">
    <div class="row">
        <div class="span12">
            <h1>Sellers welcome</h1>

            <div class="top-menu">
                <span>Период</span><input type="text">
                <span>Период</span><input type="text">
                <span>Период</span><input type="text">
                <span>Период</span><input type="text">
                <span>Период</span><input type="text">
                <input type="button">
            </div>
            <table class="table table-bordered table-hover table-condensed">
                <thead>
                <tr>
                    <th>id</th>
                    <th>Email</th>
                    <th>Телефон</th>
                    <th>Дата регистрации</th>
                    <th>Сайт откуда первый раз пришел</th>
                    <th>Первый поисковый запрос</th>
                    <th>Оплата</th>
                    <th>Счет/Реализация/Счет фактура</th>
                    <th>Журнал посещений</th>
                    <th>Журнал коммуникаций</th>
                    <th>Статус</th>
                </tr>
                </thead>
                <c:forEach items="${gridRows}" var="cur">
                    <tr>
                        <td>${cur.id }</td>
                        <td>${cur.email }</td>
                        <td>${cur.phone}</td>
                        <td><fmt:formatDate pattern='dd.MM.yyyy HH:mm' value='${cur.registrationDate}'/></td>
                        <td><a href="${cur.referer}">${cur.referer}</a></td>
                        <td>${cur.searchQuery}</td>
                            <%--Payments--%>
                        <td>
                            <c:forEach items="${cur.payments}" var="payment">
                                <fmt:formatDate pattern='dd.MM.yyyy' value='${payment.created}'/>
                                &nbsp;&nbsp;
                                ${payment.value} рублей
                            </c:forEach>
                        </td>

                        <td>${cur.aii}</td>
                        <td>${cur.visits}&nbsp;страниц<br><a
                                href="/seller/browsing_history?id=${cur.id}">Подробно</a></td>
                        <td>
                            <c:forEach items="${cur.communicationLog}" var="communication">
                                <a href="#">${communication.time}&nbsp;&nbsp;${communication.description}</a>
                            </c:forEach>
                        </td>
                        <td>
                             <!--Status must be here-->
                        </td>
                    </tr>
                </c:forEach>
            </table>
        </div>
    </div>
</div>

卖家欢迎
Период
Период
Период
Период
Период
身份证件
电子邮件
Телефон
Дата регистрации
Сайт откуда первый раз пришел
Первый поисковый запрос
Оплата
Счет/Реализация/Счет фактура
Журнал посещений
Журнал коммуникаций
Статус
${cur.id}
${cur.email}
${cur.phone}
${cur.searchQuery}
${payment.value}
${cur.aii}
${cur.visions}
如何在JSP中创建下拉框,以及如何为每行选择当前值?

尝试以下操作:

<select>  
    <c:forEach var="item" items="${statuses}">  
        <c:choose>
            <c:when test="${cur.status == item}">
                <option selected>${item}</option>
            </c:when>
            <c:otherwise>
                <option>${item}</option>
            </c:otherwise>
        </c:choose>
    </c:forEach>  
</select>

${item}
${item}

它必须生成下拉框,但如何选择每行的当前状态?我需要检查当前网格行的状态。如何访问具体行的当前状态?我不知道
状态
类结构状态只是一个字符串。在SellerStatistics项(代表行)中有一个字段状态(也是字符串类型)。