|
|
Publié sur 24/12/2014 02:28:19
|
|
|
|

[mw_shl_code=javascript,true]$(function(){ $(« #userName »).blur(function() { var value = $(« #userName »).val() ; verifyUserName(value) ; }); $(« #userName »).focus(function() { $(« #userNameErr »).text(« ») ; }); });
function verifyUserName(userName){ var value = $(« #userName »).val() ; $.ajax({ type : « GET », cache : faux, asynchrone :faux, url :"/bookShopping/UserServlet », data :{méthode :"verifyUserName »,userName :value}, dataType :"json », succès :fonction(résultat){ if(result.ifreg =="true »){ $(« #userNameErr »).text (« Ce nom d’utilisateur est enregistré ! ») ); } } }); }[/mw_shl_code]
[mw_shl_code=java,vrai] < %@ page language="java » import="java.util.* » pageEncoding="utf-8" %> < %@ taglib prefix="c » uri="http://java.sun.com/jsp/jstl/core" %> < !DOCTYPE HTML PUBLIC « -//W3C//DTD HTML 4.01 Transitional//EN » « http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head>
<title>Page d’inscription</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="mots-clés » content="mot-clé1,mot-clé2,mot-clé3"> <meta http-equiv="description » content="C’est ma page"> <script type="text/javascript » src="<c :url value='/jquery/jquery-1.5.1.js'/>"></script> <script type="text/javascript » src="<c :url value='/js/register.js'/>"></script> <!-- <lien rel="feuille de style » type="text/css » href="styles.css"> --> <script type="text/javascript"> fonction _hyz() { $(« #vCode »).attr(« src », '<c :url value='/VerifyCodeServlet ?'/>' + nouvelle date().getTime()) ;
} </script> </head>
<body> <form action="/bookShopping/UserServlet"> <type d’entrée="caché » nom="méthode » valeur="registre"/> Nom d’utilisateur<br/> <input id = « userName » name="userName » type="text » value="${formuser.userName }"/><label id = « userNameErr">${errors.loginname }</label><br/> Nom<br/> réel <nom d’entrée="nomTrue » type="text » valeur="${formuser.trueName } » />${errors.trueName }<br/> Mot de passe<br/> <nom d’entrée="passWord » type="password » valeur="${formuser.passWord }"/>${errors.loginpass }<br/> Confirme le mot de passe<br/> <input name="repassWord » type="password » value="${reloginpass } » />${errors.reloginpass }<br/> Ville<br/> <nom d’entrée="ville » type="text » valeur="${formuser.city }"/>${errors.city }<br/> Adresse<br/> résidentielle <nom d’entrée="adresse » type="text » valeur="${formuser.address }"/>${errors.address }<br/> Code postal<br/> <nom d’entrée="postcode » type="text » value="${formuser.postcode } » />${errors.postcode }<br/> Numéro<br/> d’identification <nom d’entrée="cardno » type="text » valeur="${formuser.cardno }"/>${errors.cartno }<br/> Types de <br/>documents <nom d’entrée="typeCard » type="text » valeur="${formuser.cardType }"/>${errors.cardType }<br/> Numéro<br/> de contact <nom d’entrée="tel » type="text » valeur="${formuser.tel }"/>${errors.tel }<br/> Messagerie électronique <br/> <entrée nom="email » type="text » value="${formuser.email }"/>${errors.email }<br/> CAPTCHA <br/><img id= « vCode » src="<c :url value='/VerifyCodeServlet'/>">${errors.verifyCode } <label> <a href="javascript :_hyz() » > en remplacer un</a></label><br/> <nom d’entrée="verifyCode » /><br/> <nom d’entrée="BtnRegister » type="submit » valeur="Register » /> <a href= « <c :url value='/index.jsp'/> » > retourner à la page d’accueil</a> </form> </body> </html> [/mw_shl_code]
[mw_shl_code=java,true]/** * AJAX vérifie si le nom d’utilisateur est enregistré * @param demande * @param respiration * @return * @throws ServletException * @throws IOException */ chaîne publique VerifyUserName (HttpServletRequest requis, HttpServletResponse resp) throws ServletException, IOException { Booléen B = faux ; try { int i = userService.verifyUserName(req.getParameter(« userName »)) ; if (i==1) { b=vrai ; } } catch (SQLException e) { TODO Bloc de capture auto-généré e.printStackTrace() ; } Données de retour au format JSON resp.getWriter().print(« {\"bool\ » :\"qqq\"} ») ; resp.getWriter().print(« {\"ifreg\ » :\""+b+"\"} ») ; resp.getWriter().print(b) ; System.out.println(« {\"ifreg\ » :\""+b+"\"} ») ; retour « » ; }[/mw_shl_code]
|
-
1.png
(226.76 KB, Nombre de téléchargements: 426)
-
2.png
(85.65 KB, Nombre de téléchargements: 428)
-
3.png
(93.44 KB, Nombre de téléchargements: 412)
-
4.png
(174.62 KB, Nombre de téléchargements: 418)
-
5.png
(77.35 KB, Nombre de téléchargements: 412)
-
6.png
(132.41 KB, Nombre de téléchargements: 387)
-
7.png
(113.82 KB, Nombre de téléchargements: 397)
Précédent:Convertisseur de temps personnalisé STRUTS2Prochain:struts2 pour obtenir les objets couramment utilisés dans le servlet
|