Bonjour,

j'ai introduit le framework Spring Security dans mon travail et ça marche avec les valeurs par défaut (j_spring_security_check j_username et j_password) j'ai essayé d'utiliser mon propre form login et ça marche aussi

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
 
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:include page="index.jsp"></jsp:include>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<body>
	<div align="center">
		<h3>Donner votre login et mot de passe </h3>
		<form action="j_spring_security_check" method="post">
 
			<table>
				<tr>
					<td>Utilisateur:</td>
					<td><input type="text" name="j_username"></td>
				</tr>
				<tr>
					<td>Mot De Passe:</td>
					<td><input type="password" name="j_password" /></td>
				</tr>
				<tr>
					<td colspan="2" align="right"><input type="submit" value="Log In">
					</td>
				</tr>
 
			</table>
			<a href="inscription.html">créer un compte !</a>
		</form>
 
	</div>
	<hr/>
	<br/>
</body>
</html>
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
 
<http use-expressions="true" >
 
		<intercept-url pattern="/login*" access="isAnonymous()" />
		<intercept-url pattern="/inscription*" access="isAnonymous()" />
		<intercept-url pattern="/pageConsomateur*" access="isAnonymous()" />
		<intercept-url pattern="/pageFournisseur*" access="isAnonymous()" />
		<intercept-url pattern="/**" access="isAuthenticated()" />
 
		<form-login login-page="/loginPage"/>
 
		<logout logout-success-url="/loginPage" />
 
	</http>
 
	<authentication-manager>
		<authentication-provider>
			<user-service>
				<user name="user" password="user" authorities="User" />
			</user-service>
		</authentication-provider>
	</authentication-manager>
lorsque j'ai voulu utiliser ma propre méthode de check j'avais une redirection à la page login

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
 
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:include page="index.jsp"></jsp:include>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<body>
	<div align="center">
		<h3>Donner votre login et mot de passe </h3>
		<form action="loginPost.html="post">
 
			<table>
				<tr>
					<td>Utilisateur:</td>
					<td><input type="text" name="username"></td>
				</tr>
				<tr>
					<td>Mot De Passe:</td>
					<td><input type="password" name="password" /></td>
				</tr>
				<tr>
					<td colspan="2" align="right"><input type="submit" value="Log In">
					</td>
				</tr>
 
			</table>
			<a href="inscription.html">créer un compte !</a>
		</form>
 
	</div>
	<hr/>
	<br/>
</body>
</html>
loginController.java

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
@RequestMapping(value = "/loginPost", method = RequestMethod.POST)
	public ModelAndView rechercher(HttpServletRequest r) {
 
		Utilisatuer u= serviceLogin.rechercher(r.getParameter("username"), r.getParameter("password"));
 
		if (u.getStatut().contains("consommateur") == true) {
			return new ModelAndView("pageConsommateur");
		} else {
			return new ModelAndView("pageFournisseur");
			}
 
	}
car j'ai plusieurs utilisateurs avec 2 types de statut différent et chaque type à ses propre pages (les données sont stockées dans un fichier)
Comment je peux faire pour utiliser ma propre méthode et pour faire la redirection chacun vers sa page (sachant que la méthode du contrôleur permet de faire ça si j'utilise pas Spring Security)??