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

Spring Java Discussion :

Problème de contextPath sur le serveur


Sujet :

Spring Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Homme Profil pro
    Développeur Java
    Inscrit en
    Octobre 2012
    Messages
    100
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Congo-Kinshasa

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : Enseignement

    Informations forums :
    Inscription : Octobre 2012
    Messages : 100
    Par défaut Problème de contextPath sur le serveur
    Bonjour,

    Mon application fonctionne bien si j'exécute sous eclypse. Mais lorsque je crée un war pour le tester en dehors de l'eclypse certains pages n'arrives pas s'aficher correctement. Comme s'elle n'arrive pas à accéder aux fichiers css se trouvant dans le dossier static/css. Par contre les pages se trouvant dans le dossier template arrivent à lire les fichiers css.

    Nom : APP1.png
Affichages : 193
Taille : 7,8 Ko

    Nom : APP2.png
Affichages : 209
Taille : 23,9 Ko

    Le second problème est je dois ajouter manuellement le contextPah de mon application pour lire les fichiers se trouvant dans le dossier template si non ils sont introuvables.

    Nom : APP3.png
Affichages : 217
Taille : 12,7 Ko

    Quand j'ajoute manuellement, j’obtiens:

    Nom : APP4.png
Affichages : 215
Taille : 22,5 Ko

    Qu'est ce que je dois changé dans mon fichier nommé template.html(layout) du dossier template:

    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
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
     
    <!DOCTYPE html>
    <html xmlns:th="http://www.thymeleaf.org"
          xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
          xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
    <head>
    <meta charset="utf-8"/>
    <title>AEROPRO</title>
     
    <link rel="stylesheet" type="text/css" href="../static/css/bootstrap.css"
        th:href="@{/css/bootstrap.css}" />
     
    <link rel="stylesheet" type="text/css" href="../static/css/mystyle.css"
        th:href="@{/css/mystyle.css}" />    
     
            <link href="../static/css/bootstrap.min.css"
                  th:href="@{/css/bootstrap.min.css}"
                  rel="stylesheet" media="screen" />
     
            <link href="../static/css/jquery.dataTables.min.css"
                  th:href="@{/css/jquery.dataTables.min.css}"
                  rel="stylesheet" media="screen" />
     
            <link href="../static/css/signin.css"
                  th:href="@{/css/signin.css}" rel="stylesheet" media="screen"/>
     
            <link href="../static/css/errors.css"
                  th:href="@{/css/errors.css}" rel="stylesheet" media="screen"/>
     
            <link href="../static/css/jquery-ui.min.css"
                  th:href="@{/css/jquery-ui.min.css}" rel="stylesheet" media="screen"/>    
     
            <link href="../static/css/mainStyle.css"
                  th:href="@{/css/mainStyle.css}" rel="stylesheet" media="screen"/>    
     
            <script src="../static/js/jquery.min.js"
            th:src="@{/js/jquery.min.js}"></script>
     
            <script src="../static/js/jquery-ui.min.js"
            th:src="@{/js/jquery-ui.min.js}"></script>
     
            <script src="../static/js/bootstrap.min.js"
            th:src="@{/js/bootstrap.min.js}"></script>
     
            <script src="../static/js/jquery.dataTables.min.js"
            th:src="@{/js/jquery.dataTables.min.js}"></script>
     
            <script src="../static/js/functions.js" th:src="@{/js/functions.js}"></script>
         <style>
                /*navbar overrided*/
                .navbar-default {
                    background-color: #045491;
                    border-color: #000000;
                }
                .navbar-default .navbar-text{color:#ffffff}
                .navbar-brand:hover{color:#000000;background-color:transparent}
                .navbar-default .navbar-nav>li>a{color:#ffffff}   
                .navbar-default .navbar-nav > .open > a:focus {
                    color: #fff;
                    background-color: #021C10;
                }
                /*dropdown overrided*/
                .dropdown-menu>li>a{color:#040FE9}
                .dropdown-menu>li>a:hover{color:#ffffff;background-color:#045491}
          </style>
     
     
    </head>
    <body>
      <!-- entete -->
     
       <header>
    		  <div class="navbar navbar-inverse navbar-fixed-top">
    		      <div class="container">
    		        <div class="navbar-header">
     
    		          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
    		            <span class="sr-only">Toggle navigation</span>
    		            <span class="icon-bar"></span>
    		            <span class="icon-bar"></span>
    		            <span class="icon-bar"></span>
    		          </button>
    		          <a class="navbar-brand" href="#">AeroPro</a>
    		        </div>
     
    		        <div class="collapse navbar-collapse">
    		          <ul class="nav navbar-nav">
    		            <li class="active"><a href="/" th:href="@{/}">Home</a></li>
     
    		            <li class="dropdown" sec:authorize="hasRole('ROLE_ADMIN')">   
    		                                <a href="#" class="dropdown-toggle" 
    		                                   data-toggle="dropdown" role="button" 
    		                                   aria-haspopup="true" aria-expanded="false">Personnels<span class="caret"></span></a>
    		                                <ul class="dropdown-menu">
    		                                    <li><a href="/personnels/index" th:href="@{/personnels/index}">Liste personnels</a></li>
    		                                    <li><a href="/personnels/nouveau" th:href="@{/personnels/nouveau}">Nouveau personnel</a></li>
    		                                    <li><a href="/qualification/index" th:href="@{/qualification/index}">Qualification</a></li>		                               
    		                                    <li><a href="/aptitude/index" th:href="@{/aptitude/index}">Aptitude physique</a></li>
     
     
    		                                </ul>
    		            </li> 
    		            <!--Essayons de masque si c'est pas ADMIN OU PEL  -->
     
    		            <li class="dropdown" sec:authorize="hasRole('ROLE_ADMIN')">   
    		                                <a href="#" class="dropdown-toggle" 
    		                                   data-toggle="dropdown" role="button" 
    		                                   aria-haspopup="true" aria-expanded="false">Licence<span class="caret"></span></a>
    		                                <ul class="dropdown-menu">
    		                                    <li><a href="/licence/index" th:href="@{/licence/index}">Liste licences</a></li>
    		                                    <li><a href="/licence/index" th:href="@{/licence/nouvelle}">Nouvelle licence</a></li>
    		                                    <li><a href="/validation/index" th:href="@{/validation/nouvelle}">Validation licence</a></li>		                               
    		                                    <li><a href="/typelicence/index" th:href="@{/typelicence/index}">Type licence</a></li>
     
     
    		                                </ul>
    		            </li> 
     
    		              <li class="dropdown" >   
    		                                <a href="#" class="dropdown-toggle" 
    		                                   data-toggle="dropdown" role="button" 
    		                                   aria-haspopup="true" aria-expanded="false">Opération Bancaire<span class="caret"></span></a>
    		                                <ul class="dropdown-menu">
    		                                    <li><a href="/paiement/index" th:href="@{/paiement/index}">Paiement</a></li>		                               
    		                                    <li><a href="/devise/index" th:href="@{/devise/index}">Devise</a></li>
    		          							<li><a href="/coursechange/index" th:href="@{/coursechange/index}">Cours de change</a></li>
    		          							<li><a href="/tarification/index" th:href="@{/tarification/index}">Tarification</a></li>		                               
     
    		                                </ul>
    		            </li> 
     
    		            <li class="dropdown">   
    		                                <a href="#" class="dropdown-toggle" 
    		                                   data-toggle="dropdown" role="button" 
    		                                   aria-haspopup="true" aria-expanded="false">Administration<span class="caret"></span></a>
    		                                <ul class="dropdown-menu">
    		                                     <li><a href="/categorie/index" th:href="@{/categorie/index}">Catégorie</a></li>
    		          							    <li><a href="/agent/index" th:href="@{/agent/index}">Agent</a></li>
    		          							   <li><a href="/utilisateur/index" th:href="@{/utilisateur/index}">Utilisateur</a></li>		            
    		                               			<li><a href="/utilisateur/index" th:href="@{/utilisateur/index}">Gestion des rôles</a></li>		            
     
    		                                </ul>
    		            </li> 
    		              <li class="dropdown">   
     
    		            <li><a href="#">Contact</a></li>
    		          </ul>
     
    		          <ul class="nav navbar-nav navbar-right">           
    		            <li><a th:href="@{/login?logout}">Logout</a></li>           
    		          </ul>
    		        </div>
     
    	<!-- <div sec:authorize="hasRole('ROLE_ADMIN')">
          <li><a th:href="@{/admin/switchUser}">Switch User</a></li>
         </div> -->
     
         </header>
     
          <!-- contenu de la page -->  
         <section layout:fragment="content"></section>
     
    	 <!-- footer -->    
    	<!--  <footer>
    	    <div class="navbar fixed-bottom">
    	    	WANGI NGOY ERIC
    	    </div>
    	 </footer> -->
     
    </body>
    </html>
    page index du dossier static:
    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
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
     
    <!DOCTYPE html>
    <html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="template">
     
    <head>
    <meta charset="utf-8"/>
    <title>Bienvenu(e)</title>
    <link rel="stylesheet" type="text/css" href="/css/bootstrap.css"
        th:href="@{/css/bootstrap.css}" />
     
    <link rel="stylesheet" type="text/css" href="../static/css/mystyle.css"
        th:href="@{/css/mystyle.css}" />    
     
            <link href="/css/bootstrap.min.css"
                  th:href="@{/css/bootstrap.min.css}"
                  rel="stylesheet" media="screen" />
     
            <link href="/css/jquery.dataTables.min.css"
                  th:href="@{/css/jquery.dataTables.min.css}"
                  rel="stylesheet" media="screen" />
     
            <link href="/css/signin.css"
                  th:href="@{/css/signin.css}" rel="stylesheet" media="screen"/>
     
            <link href="/css/errors.css"
                  th:href="@{/css/errors.css}" rel="stylesheet" media="screen"/>
     
            <link href="/css/jquery-ui.min.css"
                  th:href="@{/css/jquery-ui.min.css}" rel="stylesheet" media="screen"/>    
     
            <link href="/css/mainStyle.css"
                  th:href="@{/css/mainStyle.css}" rel="stylesheet" media="screen"/>    
     
            <script src="/js/jquery.min.js"
            th:src="@{/js/jquery.min.js}"></script>
     
            <script src="/js/jquery-ui.min.js"
            th:src="@{/js/jquery-ui.min.js}"></script>
     
            <script src="/js/bootstrap.min.js"
            th:src="@{/js/bootstrap.min.js}"></script>
     
            <script src="/js/jquery.dataTables.min.js"
            th:src="@{/js/jquery.dataTables.min.js}"></script>
     
            <script src="/js/functions.js" th:src="@{/js/functions.js}"></script>
         <style>
                /*navbar overrided*/
                .navbar-default {
                    background-color: #045491;
                    border-color: #000000;
                }
                .navbar-default .navbar-text{color:#ffffff}
                .navbar-brand:hover{color:#000000;background-color:transparent}
                .navbar-default .navbar-nav>li>a{color:#ffffff}   
                .navbar-default .navbar-nav > .open > a:focus {
                    color: #fff;
                    background-color: #021C10;
                }
                /*dropdown overrided*/
                .dropdown-menu>li>a{color:#040FE9}
                .dropdown-menu>li>a:hover{color:#ffffff;background-color:#045491}
          </style>
     
     
    </head>
    <body>
      <!-- entete -->
     
      <header>
    		  <div class="navbar navbar-inverse navbar-fixed-top">
    		      <div class="container">
    		        <div class="navbar-header">
     
    		          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
    		            <span class="sr-only">Toggle navigation</span>
    		            <span class="icon-bar"></span>
    		            <span class="icon-bar"></span>
    		            <span class="icon-bar"></span>
    		          </button>
    		          <a class="navbar-brand" href="#">AeroPro</a>
    		        </div>
     
    		        <div class="collapse navbar-collapse">
    		          <ul class="nav navbar-nav">
    		            <li class="active"><a href="/" th:href="@{/}">Home</a></li>
     
    		            <li class="dropdown" sec:authorize="hasRole('ROLE_ADMIN')">   
    		                                <a href="#" class="dropdown-toggle" 
    		                                   data-toggle="dropdown" role="button" 
    		                                   aria-haspopup="true" aria-expanded="false">Personnels<span class="caret"></span></a>
    		                                <ul class="dropdown-menu">
    		                                    <li><a href="/personnels/index" th:href="@{/personnels/index}">Liste personnels</a></li>
    		                                    <li><a href="/personnels/nouveau" th:href="@{/personnels/nouveau}">Nouveau personnel</a></li>
    		                                    <li><a href="/qualification/index" th:href="@{/qualification/index}">Qualification</a></li>		                               
    		                                    <li><a href="/aptitude/index" th:href="@{/aptitude/index}">Aptitude physique</a></li>
     
     
    		                                </ul>
    		            </li> 
    		            <!--Essayons de masque si c'est pas ADMIN OU PEL  -->
     
    		            <li class="dropdown" sec:authorize="hasRole('ROLE_ADMIN')">   
    		                                <a href="#" class="dropdown-toggle" 
    		                                   data-toggle="dropdown" role="button" 
    		                                   aria-haspopup="true" aria-expanded="false">Licence<span class="caret"></span></a>
    		                                <ul class="dropdown-menu">
    		                                    <li><a href="/licence/index" th:href="@{/licence/index}">Liste licences</a></li>
    		                                    <li><a href="/licence/index" th:href="@{/licence/nouvelle}">Nouvelle licence</a></li>
    		                                    <li><a href="/validation/index" th:href="@{/validation/nouvelle}">Validation licence</a></li>		                               
    		                                     <li><a href="/typelicence/index" th:href="@{/typelicence/index}">Type licence</a></li>
     
     
    		                                </ul>
    		            </li> 
     
    		              <li class="dropdown" >   
    		                                <a href="#" class="dropdown-toggle" 
    		                                   data-toggle="dropdown" role="button" 
    		                                   aria-haspopup="true" aria-expanded="false">Opération Bancaire<span class="caret"></span></a>
    		                                <ul class="dropdown-menu">
    		                                    <li><a href="/paiement/index" th:href="@{/paiement/nouvelle}">Paiement</a></li>		                               
    		                                    <li><a href="/devise/index" th:href="@{/devise/index}">Devise</a></li>
    		          							<li><a href="/coursechange/index" th:href="@{/coursechange/index}">Cours de change</a></li>
    		          							<li><a href="/tarification/index" th:href="@{/tarification/index}">Tarification</a></li>		                               
     
    		                                </ul>
    		            </li> 
     
    		            <li class="dropdown">   
    		                                <a href="#" class="dropdown-toggle" 
    		                                   data-toggle="dropdown" role="button" 
    		                                   aria-haspopup="true" aria-expanded="false">Administration<span class="caret"></span></a>
    		                                <ul class="dropdown-menu">
    		                                     <li><a href="/categorie/index" th:href="@{/categorie/index}">Catégorie</a></li>
    		          							  <li><a href="/devise/index" th:href="@{/devise/index}">Devise</a></li>
    		          							   <li><a href="/coursechange/index" th:href="@{/coursechange/index}">Cours de change</a></li>
    		          							   <li><a href="/agent/index" th:href="@{/agent/index}">Agent</a></li>
    		          							   <li><a href="/utilisateur/index" th:href="@{/utilisateur/index}">Utilisateur</a></li>		            
    		                               			<li><a href="/utilisateur/index" th:href="@{/utilisateur/index}">Gestion des rôles</a></li>		            
     
    		                                </ul>
    		            </li> 
    		              <li class="dropdown">   
     
    		            <li><a href="#">Contact</a></li>
    		          </ul>
     
    		          <ul class="nav navbar-nav navbar-right">           
    		            <li><a href="/login?logout" th:href="@{/login?logout}">Logout</a></li>           
    		          </ul>
    		        </div>
     
    	<!-- <div sec:authorize="hasRole('ROLE_ADMIN')">
          <li><a th:href="@{/admin/switchUser}">Switch User</a></li>
         </div> -->
     
         </header>
     
        <!-- contenue de la page -->
       <div layout:fragment="content">
         <!--  <h3>
    	    Welcome : <span th:utext="${#request.userPrincipal.name}"></span>
     
    	  </h3> -->
    	  <div >
    	    <br/><br/><br/>
    	  	<center><img class="img-circle" src="/images/logoaeropro.jpg" /></center>
     
    	  </div>
     
       </div>
     
     
           <div th:fragment="footer">
                <div class="container">
                    <br/>
                    <div style="background-color: #021C10;">
                        <p style="color: #ffffff; font-size: 16px; text-align: center;">Copyright ©. ERIC WANGI NGOY</p>
     
                    </div>
                </div>            
            </div>
     
    </body>
    </html>
    Images attachées Images attachées  

  2. #2
    Membre Expert Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Par défaut
    Salut,
    peux tu nous dire ce qu´il ya dans le fichier: src/main/resources/application.properties

    Merci

    Jeffray

  3. #3
    Membre confirmé
    Homme Profil pro
    Développeur Java
    Inscrit en
    Octobre 2012
    Messages
    100
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Congo-Kinshasa

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : Enseignement

    Informations forums :
    Inscription : Octobre 2012
    Messages : 100
    Par défaut
    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
     
    spring.datasource.url=jdbc:mysql://localhost:3306/aeropro2018
    spring.datasource.username=root
    spring.datasource.password=
    spring.datasource.driver-class-name=com.mysql.jdbc.Driver
    spring.jpa.show-sql=true
    spring.jpa.hibernate.ddl-auto=update
    spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
    #je change mon port pour tomcat
    server.port=8084
    #configuration de la taille de la photo
    multipart.maxFileSize=10000KB
    multipart.maxRequestSize=10000KB
    #ici le dossier(aeroimages) de la photo se trouve dans le compte utilisateur du serveur(machine)
    dir.images=${user.home}/aeroimages/
    #configuration basic pour l'utilisateur
    #spring.security.user.name=admin
    #spring.security.user.password=eriwang
    server.session-timeout=5

  4. #4
    Membre Expert Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Par défaut
    Salut ,
    tu devras le configurer dans ton nouveau serveur.
    ou bien le definir dans ton pom.xml comme finalname:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <build>
    ...
    <finalName>tonAppl</finalName>
    </build>
    ceci te permet de l´exporter en tant que tonAppl.war qui sera automatiquement pris par ton nouveau serveur comme ton context.


    Eric

  5. #5
    Membre confirmé
    Homme Profil pro
    Développeur Java
    Inscrit en
    Octobre 2012
    Messages
    100
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Congo-Kinshasa

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : Enseignement

    Informations forums :
    Inscription : Octobre 2012
    Messages : 100
    Par défaut
    Bonjour,
    ça marche avec le context mais je ne comprend pas pourquoi après avoir se connecter la page index se trouvant dans le dossier static n'arrive pas à lire les fichiers css et boostrap.

    Est ce que je dois toujours créer cette page index dans static ou je peux la créée dans le dossier template pour palier à cette situation.

    Mon fichier securityConfig se présente comme suit:

    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
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
     
    package com.wangi.aeropro;
     
    import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.handler;
     
    import javax.sql.DataSource;
     
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
    import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
    import org.springframework.security.config.annotation.web.builders.HttpSecurity;
    import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
    import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
    import org.springframework.security.core.userdetails.UserDetailsService;
    import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
    import org.springframework.security.crypto.password.NoOpPasswordEncoder;
    import org.springframework.security.crypto.password.PasswordEncoder;
    import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
     
     
    @Configuration
    @EnableWebSecurity
    @EnableGlobalMethodSecurity(securedEnabled=true)
    public class SecurityConfig extends WebSecurityConfigurerAdapter{
     
     
    	@Bean
    	public PasswordEncoder passwordEncoder(){
    		PasswordEncoder encoder = new BCryptPasswordEncoder();
    		return encoder;
    	}
     
    	@Autowired
    	public void globalConfig(AuthenticationManagerBuilder auth,DataSource dataSource) throws Exception {
    		/*auth.inMemoryAuthentication().withUser("admin").password("{noop}eriwang").roles("ADMIN","PEL","CAISSE");
    		auth.inMemoryAuthentication().withUser("wangi").password("{noop}123456789").roles("PEL");
    		auth.inMemoryAuthentication().withUser("buzi").password("{noop}123").roles("VISITEUR");*/
    		auth.jdbcAuthentication()
    			.dataSource(dataSource)
    			.passwordEncoder(passwordEncoder())
    			.usersByUsernameQuery("select name as principal,password as credentials,true from users where name=?")
    			.authoritiesByUsernameQuery("select users_name as principal,roles_name as role from users_roles where users_name=?")
    			.rolePrefix("ROLE_");
     
    	}
     
    	@Override
    	protected void configure(HttpSecurity http) throws Exception {
    		http
    		.sessionManagement().sessionFixation().newSession()
    		.invalidSessionUrl("/login")
            .maximumSessions(1)
            .expiredUrl("/login")
            .maxSessionsPreventsLogin(false);
     
    		http
    			.csrf()
    			.and()
    			.authorizeRequests()
    				.antMatchers("/css/**","/images/**","/js/**").permitAll()
    					.anyRequest()
    						.authenticated()						
    							.and()
    			.formLogin()
    				.loginPage("/login")
    				.permitAll()
    			.defaultSuccessUrl("/index.html")			
    			/*.failureUrl("/error.html")*/
    			.and()
    			.logout()
                	.invalidateHttpSession(true)
                	.clearAuthentication(true)
                	.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
    		     .and().exceptionHandling().accessDeniedPage("/access_denied.html");  
     
    	}		
     
     
     
     
    	 /*@Bean
    	 public static NoOpPasswordEncoder passwordEncoder() {
    	  return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance();
    	 }*/
     
    }

  6. #6
    Membre Expert Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Par défaut
    salut,
    as tu resolue ton probleme si oui comment?
    cela pourra aider les autres qui pourront avoir le meme probleme.

    Jeffray

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 7
    Dernier message: 27/10/2006, 15h16
  2. Problème d'accent sur un serveur UNIX
    Par geji dans le forum Langage
    Réponses: 6
    Dernier message: 20/04/2006, 07h50
  3. Problème de lettre sur nouveau serveur
    Par gobs dans le forum Langage
    Réponses: 2
    Dernier message: 19/01/2006, 23h31
  4. problème de connection sur un serveur
    Par chti_juanito dans le forum Outils
    Réponses: 1
    Dernier message: 12/01/2006, 21h35
  5. [9i] Problème de perfomance sur un serveur
    Par Débéa dans le forum Oracle
    Réponses: 3
    Dernier message: 20/09/2005, 17h23

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