控制器中的动作被调用了两次

时间:2018-08-27 11:12:01

标签: javascript jquery ajax spring

我的项目有一个小问题。 表单验证后,我使用javaScript文件检查输入,然后将结果发送到控制器,但是目标方法被调用了两次。我不明白为什么,也无法弄清楚。请帮助我。.

signup.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>

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

<c:set var="js">
  <!-- Script for the signup action -->
  <script type="text/javascript" src="static/js/takeandgo.signup.js"></script>
</c:set>

<c:set value="Inscription | TakeAndGo" var="title"></c:set>

<c:set var="body">

<section class="engine">
    <a href="signup">Inscription | TakeAndGo</a>
</section>

<br>
<br>
<br>
<br>

<nav aria-label="breadcrumb">
    <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href=".">Home</a></li>
        <li class="breadcrumb-item active" aria-current="page">Inscription</li>
    </ol>
</nav>

<div class="container">
    <div class="card">
        <div class="card-header">Inscription</div>
        <div class="card-body">
            <h6 class="card-title">Veuillez remplir les champs ci-dessous</h6>

            <form:form id="ajax-signup" modelAttribute="user">
                <div class="form-group">
                    <form:label path="prenom">Prénom *</form:label>
                    <form:input id="ajax-name" type="text" path="prenom"
                        class="form-control" value="${client.name}" name="name"
                        required="required"></form:input>
                    <small id="prenom" class="form-text">Doit contenir que des
                        lettres</small>
                </div>

                <div class="form-group">
                    <form:label path="email">Email *</form:label>
                    <form:input id="ajax-email" type="email" path="email"
                        class="form-control" value="${client.email}" name="email"
                        required="required"></form:input>
                    <small id="email" class="form-text">Doit respecter un
                        format mail valide</small>
                        <small id="mailStatus" class="form-text" style="color: red"></small>
                </div>

                <div class="form-group">
                    <form:label path="tel">Téléphone *</form:label>
                    <form:input id="ajax-tel" type="number" path="tel"
                        class="form-control" value="${client.tel}" name="tel"
                        onKeypress="
 if(event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;
 if(event.which < 45 || event.which > 57) return false;"
                        pattern="^[0-8]{10}$" minlength="10" maxlength="10"
                        required="required"></form:input>
                    <small id="tel" class="form-text">Doit respecter un format
                        de téléhone valide</small>
                </div>
                <div class="form-group">
                    <form:label path="naissance">Date de naissance *</form:label>
                    <form:input id="ajax-naissance" type="date" path="naissance"
                        class="form-control" value="${client.naissance}" name="naissance"
                        required="required"></form:input>
                    <small id="birth"></small>
                </div>

                <div class="form-group">
                    <form:label path="password">Mot de passe *</form:label>
                    <form:input id="ajax-password" type="password" path="password"
                        class="form-control" value="${client.password}" name="password"
                        required="required"></form:input>
                    <small id="mdp"></small>
                </div>
                <button type="button" id="btn-submit" class="btn btn-primary"
                    data-toggle="modal" data-target="#modal">Soumettre</button>
            </form:form>

            <!-- Script for the signup action -->
            <script type="text/javascript" src="static/js/takeandgo.signup.js"></script>

        </div>
        <div class="card-footer text-muted">Les champs marqués d'une
            (*) sont obligatoires</div>
    </div>

    <!-- Modal -->
    <div class="modal fade" id="modal" tabindex="-1" role="dialog"
        aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">Dernière étape</h5>
                </div>
                <div class="modal-body">Vos informations ont été sauvegardé.
                    Un mail vous a été envoyer pour vérifier votre mail et finaliser
                    votre inscription</div>
                <div class="modal-footer">
                    <a href="."><button type="button" class="btn btn-primary">Compris
                            !</button></a> <a href="signin"><button type="button"
                            class="btn btn-ligth">Connexion</button></a>
                </div>
            </div>
        </div>
    </div>

</div>
</c:set>

<%@ include file="/WEB-INF/views/base.jsp"%>

takeandgo.signup.js

$(function(){

$("#ajax-name").keyup(function(){

    var prenomReg = new RegExp("^[A-Za-zÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ-]+$");

    if(prenomReg.test($("#ajax-name").val())){
        $("#prenom").removeClass("fa fa-close");
        $("#prenom").addClass("fa fa-check");
        $("#prenom").css("color","green");
    }else{
        $("#prenom").removeClass("fa fa-check");
        $("#prenom").addClass("fa fa-close");
        $("#prenom").css("color","red");
    }

});

$("#ajax-email").keyup(function(){
    //pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$"
    var emailReg = new RegExp("[a-z0-9._%+-]+@[a-z0-9.-_]+\.[a-z]{2,3}$");

    if(emailReg.test($("#ajax-email").val())){
        $("#email").removeClass("fa fa-close");
        $("#email").addClass("fa fa-check");
        $("#email").css("color","green");
    }else{
        $("#email").removeClass("fa fa-check");
        $("#email").addClass("fa fa-close");
        $("#email").css("color","red");
    }

});

$('#btn-submit').on('click',function(){
    $.ajax({

        type:'post',
        url:'creat-client',
        data: {name : $("#ajax-name").val(), email:  $("#ajax-email").val(),password : $("#ajax-password").val(),tel : $("#ajax-tel").val(),naissance : $("#ajax-naissance").val()},
        success: function(responseJSON) {

            if(responseJSON['SUCCESS'] == 'OK')
            {
                setValidMessageById('#form-messages','Thank you . Inscription success');
                setAllValidInput();
                //window.location.replace(responseJSON['REDIRECT']);


            }
            else{

                setInvalidMessageById('#form-messages','Inscription faild retry');

                validOrInvalid(responseJSON['NAME'],'#ajax-name');
                validOrInvalid(responseJSON['EMAIL'],'#ajax-email');
                validOrInvalid(responseJSON['PASSWORD'],'#ajax-password');
                validOrInvalid(responseJSON['TEL'],'#ajax-tel');
                validOrInvalid(responseJSON['NAISSANCE'], '#ajax-naissance');

            }

        }

    });

});

function setInvalidInputById(id){
    $(id).removeClass('is-valid');
    $(id).addClass('is-invalid');
}
function setValidInputById(id){
    $(id).removeClass('is-invalid');
    $(id).addClass('is-valid');
}
function validOrInvalid(rspJSONValue,id){
    if(rspJSONValue != null)
    {
        if(rspJSONValue == 'KO')
        {
            $(id).val('');
            setInvalidInputById(id);    
        }
        else if(rspJSONValue == 'OK')
        {
            setValidInputById(id);  
        }
    }
}
function setInvalidMessageById(id,message){
    $(id).text(message);
    $(id).removeClass('alert alert-success');
    $(id).addClass('alert alert-danger');
}

function setValidMessageById(id,message){
    $(id).text(message);
    $(id).removeClass('alert alert-danger');
    $(id).addClass('alert alert-success');
}

function setAllValidInput(){
    $('#ajax-name').val('');
    setValidInputById('#ajax-name');
    $('#ajax-email').val('');       
    setValidInputById('#ajax-email');
    $('#ajax-password').val('');    
    setValidInputById('#ajax-email');
    $('#ajax-tel').val('');     
    setValidInputById('#ajax-tel');
    $('#ajax-naissance').val('');
    setValidInputById('#ajax-naissance');
}

});

InscriptionController.java

package com.takeandgo.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.takeandgo.beans.Client;
import com.takeandgo.dao.ClientDao;
import com.takeandgo.utils.RandomCodeGenerator;
import com.takeandgo.utils.SendMail;

/**
 * A class to test interactions with the MySQL database using the ClientDAO
 * class.
 *
 * @author KAMBI Ben
 */
//@ComponentScan("com.takeandgo.dao.ClientDao")
@Controller
@Component 
public class InscriptionController {

    // ------------------------
    // PUBLIC METHODS
    // ------------------------

@Autowired
private ClientDao clientDao;

/**
 * Create a new user and save it in the database.
 * 
 * @param model
 * @throws IOException
 * @throws JSONException
 */
@RequestMapping(value = "/creat-client", method= RequestMethod.POST)
@ResponseBody
public void create(HttpServletRequest req, HttpServletResponse res, Model model) throws IOException, JSONException {
    System.out.println("-- in creat-client Action --");

    String name = req.getParameter("name");
    String email = req.getParameter("email");
    String password = req.getParameter("password");
    String tel = req.getParameter("tel");
    String naissance = req.getParameter("naissance");
    JSONObject json = new JSONObject();
    // name.matches(regExpression);

    String code = null;
    RandomCodeGenerator rnd = new RandomCodeGenerator();
    SendMail mail = new SendMail();

    System.out.println(name+ " - " +  email + " - " + password + " - " + tel + " - " + naissance);
    if (name.length() != 0 && email.length() != 0 && password.length() != 0 && tel.length() != 0
            && naissance.length() != 0) {
        json.put("SUCCESS", "OK");
        json.put("REDIRECT", "/takeandgo/");

        Client clientToSave = new Client(name, email, password, tel, naissance);

        model.addAttribute("client", clientToSave);

//          if(clientDao.isMailAvailable(clientToSave)) {
//
//          //code = rnd.codeGeneratorForEmail();
//          //mail.sendVerificationLink(name, email, code);
//          
//          //clientDao.addClient(clientToSave, code);
//          model.addAttribute("inscription", "ok");
//          model.addAttribute("prenom", name);
//          model.addAttribute("email", email);
//          model.addAttribute("password", password);
//          model.addAttribute("tel", tel);
//          model.addAttribute("naissance", naissance);
//          
//          }else {
//              model.addAttribute("mailAvailable", "unavailable");
//          }

    } else {

        if (name != null) {

            if (name.length() == 0) {
                json.put("NAME", "KO");

            }
            if (name.length() > 0) {
                json.put("NAME", "OK");

            }

        }
        if (email != null) {

            if (email.length() == 0) {
                json.put("EMAIL", "KO");

            }
            if (email.length() > 0) {
                json.put("EMAIL", "OK");

            }

        }
        if (password != null) {

            if (password.length() == 0) {
                json.put("PASSWORD", "KO");

            }
            if (password.length() > 0) {
                json.put("PASSWORD", "OK");

            }

        }
        if (tel != null) {

            if (tel.length() == 0) {
                json.put("TEL", "KO");

            }
            if (tel.length() > 0) {
                json.put("TEL", "OK");

            }

        }
        if (naissance != null) {

            if (naissance.length() == 0) {
                json.put("NAISSANCE", "KO");

            }
            if (naissance.length() > 0) {
                json.put("NAISSANCE", "OK");

            }

        }

    }

    returnJSON(res, json);

}

public void returnJSON(HttpServletResponse res, JSONObject json) throws IOException {
    res.setContentType("application/json");
    res.setCharacterEncoding("utf-8");
    PrintWriter out = res.getWriter();
    out.print(json.toString());
    out.flush();

}

@RequestMapping(value = "/{code}")
public ModelAndView verifiedAccount(ModelMap model, @PathVariable String code) {

    ModelAndView mv = null;

    if(clientDao.findCode(code))
    {
        clientDao.SetMailVerified(code);
        System.out.println("Verification succes");
        mv = new ModelAndView("public/Auth/MailVerificationOk");
    }else {

        System.out.println("Verification failed.... Something went wrong");
        mv = new ModelAndView("public/Auth/MailVerificationFailed");
    }

    return mv;  
}

}

这是测试题字后控制台显示的内容

      .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.3.5.RELEASE)

2018-08-27 12:15:12.109  INFO 3920 --- [  restartedMain] com.takeandgo.WebApplication             : Starting WebApplication on DESKTOP-TIVV4OD with PID 3920 (E:\ISN\Perso\TAG\olamide\takeandgo\TakeAndGo\target\classes started by Olamidé in E:\ISN\Perso\TAG\olamide\takeandgo\TakeAndGo)
2018-08-27 12:15:12.115  INFO 3920 --- [  restartedMain] com.takeandgo.WebApplication             : No active profile set, falling back to default profiles: default
2018-08-27 12:15:12.268  INFO 3920 --- [  restartedMain] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7f3a08eb: startup date [Mon Aug 27 12:15:12 CEST 2018]; root of context hierarchy
2018-08-27 12:15:17.542  INFO 3920 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$e0319e4f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-08-27 12:15:19.178  INFO 3920 --- [  restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 7980 (http)
2018-08-27 12:15:19.211  INFO 3920 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service Tomcat
2018-08-27 12:15:19.216  INFO 3920 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.0.33
2018-08-27 12:15:20.423  INFO 3920 --- [ost-startStop-1] org.apache.jasper.servlet.TldScanner     : 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.
2018-08-27 12:15:20.442  INFO 3920 --- [ost-startStop-1] o.a.c.c.C.[.[localhost].[/takeandgo]     : Initializing Spring embedded WebApplicationContext
2018-08-27 12:15:20.443  INFO 3920 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 8182 ms
2018-08-27 12:15:21.365  INFO 3920 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
2018-08-27 12:15:21.373  INFO 3920 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-08-27 12:15:21.374  INFO 3920 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-08-27 12:15:21.374  INFO 3920 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-08-27 12:15:21.375  INFO 3920 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'requestContextFilter' to: [/*]
2018-08-27 12:15:22.123  INFO 3920 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-08-27 12:15:22.157  INFO 3920 --- [  restartedMain] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-08-27 12:15:22.406  INFO 3920 --- [  restartedMain] org.hibernate.Version                    : HHH000412: Hibernate Core {4.3.11.Final}
2018-08-27 12:15:22.409  INFO 3920 --- [  restartedMain] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2018-08-27 12:15:22.415  INFO 3920 --- [  restartedMain] org.hibernate.cfg.Environment            : HHH000021: Bytecode provider name : javassist
2018-08-27 12:15:22.847  INFO 3920 --- [  restartedMain] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
2018-08-27 12:15:23.662  INFO 3920 --- [  restartedMain] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2018-08-27 12:15:23.931  INFO 3920 --- [  restartedMain] o.h.h.i.ast.ASTQueryTranslatorFactory    : HHH000397: Using ASTQueryTranslatorFactory
2018-08-27 12:15:24.296  INFO 3920 --- [  restartedMain] org.hibernate.tuple.PojoInstantiator     : HHH000182: No default (no-argument) constructor for class: com.takeandgo.beans.MailStatus (class must be instantiated by Interceptor)
2018-08-27 12:15:24.464  INFO 3920 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000228: Running hbm2ddl schema update
2018-08-27 12:15:24.465  INFO 3920 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000102: Fetching database metadata
2018-08-27 12:15:24.467  INFO 3920 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000396: Updating schema
2018-08-27 12:15:24.504  INFO 3920 --- [  restartedMain] o.hibernate.tool.hbm2ddl.TableMetadata   : HHH000261: Table found: takeandgo.client_clt
2018-08-27 12:15:24.504  INFO 3920 --- [  restartedMain] o.hibernate.tool.hbm2ddl.TableMetadata   : HHH000037: Columns: [clt_tel, clt_mdp, clt_naissance, clt_id, clt_login, clt_prenom]
2018-08-27 12:15:24.505  INFO 3920 --- [  restartedMain] o.hibernate.tool.hbm2ddl.TableMetadata   : HHH000108: Foreign keys: []
2018-08-27 12:15:24.505  INFO 3920 --- [  restartedMain] o.hibernate.tool.hbm2ddl.TableMetadata   : HHH000126: Indexes: [clt_id_unique]
2018-08-27 12:15:24.556  INFO 3920 --- [  restartedMain] o.hibernate.tool.hbm2ddl.TableMetadata   : HHH000261: Table found: takeandgo.demande_dmd
2018-08-27 12:15:24.557  INFO 3920 --- [  restartedMain] o.hibernate.tool.hbm2ddl.TableMetadata   : HHH000037: Columns: [dmd_montant, dmd_type_colis, dmd_clt_id, dmd_date_arrive, dmd_lieu_depart, dmd_date_depart, dmd_id, dmd_date_post, dmd_poids_colis, dmd_destination]
2018-08-27 12:15:24.557  INFO 3920 --- [  restartedMain] o.hibernate.tool.hbm2ddl.TableMetadata   : HHH000108: Foreign keys: []
2018-08-27 12:15:24.557  INFO 3920 --- [  restartedMain] o.hibernate.tool.hbm2ddl.TableMetadata   : HHH000126: Indexes: [primary]
2018-08-27 12:15:24.574  INFO 3920 --- [  restartedMain] o.hibernate.tool.hbm2ddl.TableMetadata   : HHH000261: Table found: takeandgo.status_compte_sc
2018-08-27 12:15:24.574  INFO 3920 --- [  restartedMain] o.hibernate.tool.hbm2ddl.TableMetadata   : HHH000037: Columns: [sc_clt_id, sc_clt_mail_status, sc_clt_mail, sc_clt_code]
2018-08-27 12:15:24.577  INFO 3920 --- [  restartedMain] o.hibernate.tool.hbm2ddl.TableMetadata   : HHH000108: Foreign keys: [status_compte_sc]
2018-08-27 12:15:24.577  INFO 3920 --- [  restartedMain] o.hibernate.tool.hbm2ddl.TableMetadata   : HHH000126: Indexes: [sc_clt_id_unique]
2018-08-27 12:15:24.578  INFO 3920 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000232: Schema update complete
2018-08-27 12:15:26.515  INFO 3920 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7f3a08eb: startup date [Mon Aug 27 12:15:12 CEST 2018]; root of context hierarchy
2018-08-27 12:15:26.740  INFO 3920 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/search],methods=[POST]}" onto public java.lang.String com.takeandgo.controller.AdvertController.searchAction(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,org.springframework.ui.ModelMap)
2018-08-27 12:15:26.747  INFO 3920 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/adverts],methods=[GET]}" onto public java.lang.String com.takeandgo.controller.AdvertController.advertsAction(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,org.springframework.ui.ModelMap)
2018-08-27 12:15:26.748  INFO 3920 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/search-adverts],methods=[POST],produces=[application/json]}" onto public org.springframework.http.ResponseEntity<?> com.takeandgo.controller.AdvertController.searchAdvertsAction(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,com.takeandgo.beans.Advert,org.springframework.validation.Errors)
2018-08-27 12:15:26.749  INFO 3920 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/signup],methods=[GET]}" onto public org.springframework.web.servlet.ModelAndView com.takeandgo.controller.AuthController.signupAction(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-08-27 12:15:26.750  INFO 3920 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/signin],methods=[GET]}" onto public org.springframework.web.servlet.ModelAndView com.takeandgo.controller.AuthController.signinAction(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,com.takeandgo.beans.Client,org.springframework.ui.ModelMap)
2018-08-27 12:15:26.751  INFO 3920 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/connect-client],methods=[POST]}" onto public java.lang.String com.takeandgo.controller.ConnectionController.connect(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,com.takeandgo.beans.Client,org.springframework.ui.ModelMap)
2018-08-27 12:15:26.753  INFO 3920 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public java.lang.String com.takeandgo.controller.DefaultController.error(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,org.springframework.ui.ModelMap)
2018-08-27 12:15:26.754  INFO 3920 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto public org.springframework.web.servlet.ModelAndView com.takeandgo.controller.DefaultController.indexAction(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-08-27 12:15:26.755  INFO 3920 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/hello]}" onto public java.lang.String com.takeandgo.controller.HelloController.hello(org.springframework.ui.Model,java.lang.String)
2018-08-27 12:15:26.756  INFO 3920 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/creat-client],methods=[POST]}" onto public void com.takeandgo.controller.InscriptionController.create(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,org.springframework.ui.Model) throws java.io.IOException,org.json.JSONException
2018-08-27 12:15:26.757  INFO 3920 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{code}]}" onto public org.springframework.web.servlet.ModelAndView com.takeandgo.controller.InscriptionController.verifiedAccount(org.springframework.ui.ModelMap,java.lang.String)
2018-08-27 12:15:26.765  INFO 3920 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/search]}" onto public org.springframework.web.servlet.ModelAndView com.takeandgo.controller.searchController.searchAction(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-08-27 12:15:26.928  INFO 3920 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-27 12:15:26.928  INFO 3920 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/static/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-27 12:15:27.054  INFO 3920 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-27 12:15:27.835  INFO 3920 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2018-08-27 12:15:27.969  INFO 3920 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-08-27 12:15:28.197  INFO 3920 --- [  restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 7980 (http)
2018-08-27 12:15:28.211  INFO 3920 --- [  restartedMain] com.takeandgo.WebApplication             : Started WebApplication in 17.449 seconds (JVM running for 18.876)
2018-08-27 12:16:49.757  INFO 3920 --- [nio-7980-exec-1] o.a.c.c.C.[.[localhost].[/takeandgo]     : Initializing Spring FrameworkServlet 'dispatcherServlet'
2018-08-27 12:16:49.758  INFO 3920 --- [nio-7980-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2018-08-27 12:16:49.809  INFO 3920 --- [nio-7980-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 51 ms
-- in signup Action --
-- in creat-client Action --
-- in creat-client Action --
fdghjk - test@gmail.com - azerty2018 - 0123456789 - 2018-08-05
fdghjk - test@gmail.com - azerty2018 - 0123456789 - 2018-08-05
in index Action

感谢您的帮助。...

1 个答案:

答案 0 :(得分:0)

嗨,我终于找到了问题,我在代码中两次出现了这一行,因此它提交了两次:

<script type="text/javascript" src="static/js/takeandgo.signup.js"></script>