IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Struts 2 Java Discussion :

code source de s'authentifier


Sujet :

Struts 2 Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Inscrit en
    Mars 2009
    Messages
    28
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 28
    Par défaut code source de s'authentifier
    salut,
    je vx créer un site avec Struts et j'ai un problème pour s'authentifier.
    qlq1 a le code source de s'authentifier (vérifier le login et le mot de passe dans une base de donnée)?
    si oui n'hésitez pas de me l'envoyer

    et merci

  2. #2
    Membre confirmé
    Inscrit en
    Avril 2006
    Messages
    76
    Détails du profil
    Informations forums :
    Inscription : Avril 2006
    Messages : 76
    Par défaut
    code pour la jsp :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    <%@ page contentType="text/html;charset=UTF-8" language="java"%>
    <%@ taglib uri="/struts-tags" prefix="s"%>
    <html>
    <head>
    <title>Page Login</title>
    </head>
    <body>
    <s:form>
    	<table cellpadding="0" cellspacing="0" width="500">
    		<tr>
    			<td valign="top" width="500">
    			<table cellpadding="0" cellspacing="0" height="300" width="500">
    				<tr>
    					<td > Titre </td>
    				</tr>
    				<tr>
    					<td>
    					<table>
    						<tr>
    							<td align="center">
    							<table summary="" class="tableFormulaire"cellpadding="0" cellspacing="0" width="300">
    								<tr>
    									<td width="10">&nbsp;</td>
    									<td width="100"><label>Login <font color="red" size="1">*</font></label></td>
    									<td width="150"><s:textfield label="login" name='username' /></td>
    								</tr>
    								<tr>
    									<td width="10">&nbsp;</td>
    									<td width="100"><label for="j_spring_security_check_j_password"> Mot de passe <font color="red" size="1">*</font></label></td>
    									<td width="161"><s:password name='password' /></td>
    								</tr>
    								<tr>
    									<td colspan="2"></td>
    									<td><s:submit value="Identification" ></s:submit></td>
    								</tr>
    							</table>
    						</tr>
    						<tr>
    							<td colspan="5" align="center"></td>
    						</tr>
    					</table>
    					</td>
    				</tr>
    			</table>
    			</td>
    		</tr>
    		<tr>
    		</tr>
    	</table>
    </s:form>
    </body>
    </html>
    et dans l'action :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    package .....;
     
    import Model.User;
     
     
    public class LoginAction{
     
    	private static final long serialVersionUID = 1L;
    	private User user;
        private String login;
        private String pwd;
     
     
    	/**
             * @param pwd the pwd to set
             */
        public void setPwd(String pwd) {
    		this.pwd = pwd;
    	}
     
    	/**
             * @return the pwd
             */
    	public String getPwd() {
    		return pwd;
    	}
     
          /**
             * @param login the login to set
             */
     
        public void setLogin(String login) {
    		this.login = login;
    	}
     
    	/**
             * @return the login
             */
    	public String getLogin() {
    		return login;
    	}
     
    	/**
             * @param user the user to set
             */
    	public void setUser(User user) {
    		this.user = user;
    	}
    	/**
             * @return the user
             */
    	public User getUser() {
    		return user;
    	}
     
     
        public String execute()  {
        	try
        	{	user=(User)Factory.getInstance().getUserService().log(getLogin(), getPwd());
        		if(user!=null)
        	        return SUCCESS;
        		else{ 
        		addActionError(getText("error.login.user"));
        		return ERROR;
        		}
        	}
        	catch (Exception e) {
        		e.printstacktrace();
        		return ERROR;
    		}
     
     
        }
     
    }

    Note que le code utilisé concerne bien struts2

Discussions similaires

  1. Contribuez à la FAQ et aux CODES SOURCE XML
    Par Community Management dans le forum XML/XSL et SOAP
    Réponses: 12
    Dernier message: 21/04/2008, 20h52
  2. code source de netstat
    Par calif dans le forum Développement
    Réponses: 3
    Dernier message: 28/09/2003, 08h39
  3. Defragmenteur code-source
    Par ak-k dans le forum Windows
    Réponses: 7
    Dernier message: 25/08/2003, 14h36
  4. Je cherche le code-source d'un interface de Windows
    Par Robert A. dans le forum Windows
    Réponses: 5
    Dernier message: 02/06/2003, 09h45
  5. [VB6] Code source pour modifier MsgBox
    Par khany dans le forum VB 6 et antérieur
    Réponses: 5
    Dernier message: 25/02/2003, 15h13

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo