我试图在postman中为admin创建一个登录函数,但无法获得正确凭据所需的输出。
这是登录控制器
@RequestMapping(value="/", method = RequestMethod.GET)
public String loginPage() {
return "Welcome to ABC Bank login page";
}
@PostMapping(value="/login", consumes = "application/json", produces ="application/json")
public String display(@RequestBody String userId, String password,Model m){
//System.out.println("Please Login");
System.out.println("userId" + userId);
if(userId.equals("admin") && password.equals("root")) {
return "Welcome to ABC Bank";
}else {
return "Login UnSuccessful ";
}
}
这是登录模型
@Entity
@Table(name = "login_page")
public class Login {
@Id
//@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "user_Id", nullable = false)
private String userId;
@Column(name = "password", nullable = false)
// @Length(min = 5, message = "*Your password must have at least 5 characters")
// @NotEmpty(message = "*Please provide your password")
// @JsonIgnore
private String password;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
因此,当管理员使用正确的凭据登录时,我需要执行Welcome to ABC bank。如何执行?
enter image description here
1条答案
按热度按时间fnx2tebb1#
而不是
我会考虑做一些
这可以通过标头和令牌的Map来进一步增强安全性。