Problems encountered in development – [Spring-security permission control framework]

1. When the console displays an error message: Bad credentials, there is a problem with the password. Check the password and verify it.

2. When the form form submits data, the default formdata submitted is the key-value pair form a=1&b=1

3. Configure custom login in spring-securit.xml At this time, if the front-end is not username, password, then the red part below must be added to receive the data, because the internal use is @requestParameter (“username”) to receive, and the front and back names must be consistent. Therefore, the front-end cannot use the axios post submission in vue. This submission encapsulates the data into a json object, which cannot be received by @requestParameter (“username”), so the dark horse toolbox is used here.


username-parameter="user"
password
-parameter="pass"
login
-processing-url="/sec/login.do"
authentication
-failure-forward-url="/user/loginFail.do"
authentication
-success-forward-url="/user/loginSuccess.do"/>

Security defines a control internally It is used to receive the login request. It must be consistent with the following ajax path to jump to the custom login interface.

 HM.ajax("/sec/login.do",params,function(data){

console.log(data);
if(data.flag){
location.href
="main.html";
}
else{
vue.$message.error(data.message);
}
});

4. When the front end can respond to data, but cannot jump to the page normally, when the server is abnormal, priority is given to cross-domain issues , It can be solved by adding the following code in spring-mvc

 



allowed-origins="http://localhost:8080"
allowed
-methods="GET,PUT,OPTIONS,POST,DELETE"       //option must not forget to write
allow
-credentials="true"
max
-age="3600"/>


username-parameter="user"
password
-parameter="pass"
login
-processing-url="/sec/login.do"
authentication
-failure-forward-url="/user/loginFail.do"
authentication
-success-forward-url="/user/loginSuccess.do"/>

 HM.ajax("/sec/login.do",params,function(data){

console.log(data);
if(data.flag){
location.href
="main.html";
}
else{
vue.$message.error(data.message);
}
});

 



allowed-origins="http://localhost:8080"
allowed
-methods="GET,PUT,OPTIONS,POST,DELETE"       //option must not forget to write
allow
-credentials="true"
max
-age="3600"/>

Leave a Comment

Your email address will not be published.