I am trying to create an authentication method using java angular js and mysql. I know how to pass one parameter, but I could not pass two, can you help me.
Here is my DAO method:
public Client authentifier(int numerocompte,String mdp) {
System.out.println(numerocompte + mdp);
try {
Connection con = Connexion.getConnection();
PreparedStatement ps = con.prepareStatement("select * from client WHERE numerocompte = ? AND mdp = ?");
ps.setInt(1, numerocompte);
ps.setString(2, mdp);
Client e = new Client();
ResultSet rs = ps.executeQuery();
while (rs.next()) {
e.setIdclient(rs.getInt("idclient"));
e.setNomcomplet(rs.getString("nomcomplet"));
e.setMail(rs.getString("mail"));
e.setNumerocompte(rs.getInt("numerocompte"));
e.setMdp(rs.getString("mdp"));
}
rs.close();
return e;
}catch (Exception e) {
System.out.println("Erreur avec authentifier() -->" + e.getMessage());
return (null);
}
}
Here is my controller method in wehere I would like to pass 2 parameters:
@GET
@Path("authentifier/{numerocompte}{mdp}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Client authentifier(@PathParam("numerocompte , mdp") int numerocompte, String mdp) {
ClientDao dao = new ClientDao();
System.out.println(numerocompte);
return dao.authentifier(numerocompte,mdp);
}
and here is the angular js line, where I will also pass two parameters:
$http.get('rest/client/authentifier/'+$scope.nouveauClient.numerocompte+$scope.nouveauClient.mdp).then(function(data){
alert(data.data);
})
A.Aou source
share