Plusieurs case avec JSP, Spring MVC, comment obtenir les valeurs

Les gars, pourriez-vous m'aider s'il vous plaît, j'ai bloqué avec ce problème, j'ai un formulaire, où je suis en train de choisir différents services, ce qui devrait être ajouté à l'ordre. Le problème est que je ne peux pas obtenir ces valeurs de choisi cases à cocher, il n'y a même pas de toutes les erreurs dans une console. Comme dirait ma servlet n'est jamais à court pour l'instant, j'ai essayé de la différence des moyens pour résoudre ce problème, mais rien ne m'a aidé.

Voici dans la page jsp:

<!-- SERVICE TABLE -->
    <form class="form-horizontal" action="/clients/addOrder/${client.id}" method="POST" >
    <table class="table table-striped table-bordered table-condensed" >
        <tr>
            <th><spring:message code="label.serviceId" /></th>
            <th><spring:message code="label.serviceName" /></th>
            <th><spring:message code="label.servicePrice" /></th>
            <th><spring:message code="label.actions" /></th>

        </tr>
        <c:forEach var="service" items="${servicesList}">
            <tr id="${service.service_id}">
                <td><c:out value="${service.service_id}" /></td>
                <td><c:out value="${service.service_name}" /></td>
                <td><c:out value="${service.service_price}" /></td>
                <td><input type="checkbox" name="serviceBox"
                    value="${service.service_id}" /></td>
            </tr>
        </c:forEach>
    </table>
    <div class="form-group form-group-sm">
        <div class="col-sm-offset-2 col-sm-10">
         <a class="pull-right">
            <button class="btn btn-primary" type="submit"><c:out value="Add order"/></button>
         </a>
        </div>
    </div>
    <input type="hidden" name="clientId" value="${client.id}">
    </form>

servlet

    @RequestMapping(value = "/addOrder/{clientId}", method = RequestMethod.POST)
    public String addOrder(@Valid @PathVariable("clientId") Long clientId,  @ModelAttribute("serviceBox") String[] services, BindingResult result,
            Model model) {
        System.out.println("IN addOrder POST");

        if (result.hasErrors()) {
            AllServicesEvent ase = servicesService
                    .requestAllServices(new RequestAllServicesEvent());
            model.addAttribute("servicesList", ase.getServices());
            return "addOrderForm";
        }
        System.out.println("NO MISTAKES");
        List<Services> servicesList = servicesService.requestService(new RequestServiceEvent(services)).getServicesList();
        System.out.println("Service List size: " + servicesList.size());
        if (servicesList != null && servicesList.size() > 0) {
            //update orders amount and total price
            System.out.println("IN IF METHOD");
            ClientUpdatedEvent cue = clientsService.updateClient(new UpdateClientEvent(clientId, servicesList));
            System.out.println("AFTER UPDATING CLIENTS");
            //add order to orders table, add order id, service id to order_service table
            OrderCreatedEvent oce = ordersService.addOrder(new CreateOrderEvent(clientId, servicesList));
            System.out.println("AFTER ADDING ORDERS");
            return "redirect:/clients";
        } else {
            return "addOrderForm";
        }
    }

Dans la console:

Oct 01, 2014 11:07:34 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Oct 01, 2014 11:07:34 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Oct 01, 2014 11:07:34 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4926 ms
Oct 01, 2014 11:07:34 PM org.apache.jasper.compiler.TldLocationsCache tldScanJar
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Hibernate: select clients0_.client_id as client_i1_3_, clients0_.birthdate as birthdat2_3_, clients0_.city as city3_3_, clients0_.country as country4_3_, clients0_.email as email5_3_, clients0_.first_name as first_na6_3_, clients0_.gender as gender7_3_, clients0_.last_name as last_nam8_3_, clients0_.orders as orders9_3_, clients0_.phone as phone10_3_, clients0_.total_income as total_i11_3_ from clients clients0_
Hibernate: select clients0_.client_id as client_i1_3_0_, clients0_.birthdate as birthdat2_3_0_, clients0_.city as city3_3_0_, clients0_.country as country4_3_0_, clients0_.email as email5_3_0_, clients0_.first_name as first_na6_3_0_, clients0_.gender as gender7_3_0_, clients0_.last_name as last_nam8_3_0_, clients0_.orders as orders9_3_0_, clients0_.phone as phone10_3_0_, clients0_.total_income as total_i11_3_0_ from clients clients0_ where clients0_.client_id=?
Hibernate: select services0_.service_id as service_1_4_, services0_.service_name as service_2_4_, services0_.service_price as service_3_4_ from services services0_

Et la place du résultat, je n'ai qu'une page web avec:

HTTP Status 404 - /clients/addOrder/1

--------------------------------------------------------------------------------

type Status report

message /clients/addOrder/1

description The requested resource is not available.

upd: dans ce mode de fonctionnement:

@RequestMapping(value = "/addOrder/{clientId}", method = RequestMethod.POST)
public String addOrder(@PathVariable("clientId") Long clientId) {
    System.out.println("IN addOrder POST, id" + clientId);
    return "addOrderForm";
}

De sorte que le seul problème comment, dans la bonne façon d'obtenir checkboxed valeurs dans le servlet.

  • Vous requestmapping est à /addOrder/{clientId} et les soumet à /clients/addOrder/${client.id}. Qui ne regarde pas le droit de me.
  • j'ai commencé à vérifier vide servlet. il fonctionne avec ces paramètres: @RequestMapping(valeur = "/addOrder/{idclient}", method = RequestMethod.POST) public String addOrder(@PathVariable("clientId") de Long clientId) { System.out.println("DANS addOrder POST", "id" + clientId); return "addOrderForm"; }
InformationsquelleAutor Cooler | 2014-10-01