why asynchronous influence controller in spring mvc?
up vote
0
down vote
favorite
No.1 when my controller is:
@RestController
public class TestController{
@GetMapping(value="/test")
public CompletableFuture<Object> testController(){
.....
return CompletableFuture.completedFuture(XXX)
}
when i run this controller code, i find preHandle log 2 times in HandlerInterceptorAdapter
No.2 when my controller is:
public Callable<Object> getTokenService(HttpSession httpSession) {
Map<String, Object> map = new HashMap<>(8);
String token = UUID.randomUUID().toString();
httpSession.setAttribute("token", token);
map.put("data", httpSession.getAttribute("token"));
return () -> map;
}
public Callable<Object> getTokenController(HttpSession httpSession){
return () -> service.getTokenService();
}
when i run this controller code, (session is stored redis),i find just when i start tomcat server and run this ,session is changed,after i run again, session isn`t changed anymore
java spring spring-mvc
add a comment |
up vote
0
down vote
favorite
No.1 when my controller is:
@RestController
public class TestController{
@GetMapping(value="/test")
public CompletableFuture<Object> testController(){
.....
return CompletableFuture.completedFuture(XXX)
}
when i run this controller code, i find preHandle log 2 times in HandlerInterceptorAdapter
No.2 when my controller is:
public Callable<Object> getTokenService(HttpSession httpSession) {
Map<String, Object> map = new HashMap<>(8);
String token = UUID.randomUUID().toString();
httpSession.setAttribute("token", token);
map.put("data", httpSession.getAttribute("token"));
return () -> map;
}
public Callable<Object> getTokenController(HttpSession httpSession){
return () -> service.getTokenService();
}
when i run this controller code, (session is stored redis),i find just when i start tomcat server and run this ,session is changed,after i run again, session isn`t changed anymore
java spring spring-mvc
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
No.1 when my controller is:
@RestController
public class TestController{
@GetMapping(value="/test")
public CompletableFuture<Object> testController(){
.....
return CompletableFuture.completedFuture(XXX)
}
when i run this controller code, i find preHandle log 2 times in HandlerInterceptorAdapter
No.2 when my controller is:
public Callable<Object> getTokenService(HttpSession httpSession) {
Map<String, Object> map = new HashMap<>(8);
String token = UUID.randomUUID().toString();
httpSession.setAttribute("token", token);
map.put("data", httpSession.getAttribute("token"));
return () -> map;
}
public Callable<Object> getTokenController(HttpSession httpSession){
return () -> service.getTokenService();
}
when i run this controller code, (session is stored redis),i find just when i start tomcat server and run this ,session is changed,after i run again, session isn`t changed anymore
java spring spring-mvc
No.1 when my controller is:
@RestController
public class TestController{
@GetMapping(value="/test")
public CompletableFuture<Object> testController(){
.....
return CompletableFuture.completedFuture(XXX)
}
when i run this controller code, i find preHandle log 2 times in HandlerInterceptorAdapter
No.2 when my controller is:
public Callable<Object> getTokenService(HttpSession httpSession) {
Map<String, Object> map = new HashMap<>(8);
String token = UUID.randomUUID().toString();
httpSession.setAttribute("token", token);
map.put("data", httpSession.getAttribute("token"));
return () -> map;
}
public Callable<Object> getTokenController(HttpSession httpSession){
return () -> service.getTokenService();
}
when i run this controller code, (session is stored redis),i find just when i start tomcat server and run this ,session is changed,after i run again, session isn`t changed anymore
java spring spring-mvc
java spring spring-mvc
asked Nov 17 at 15:15
Lce Man
134
134
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53352533%2fwhy-asynchronous-influence-controller-in-spring-mvc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown