Мой первый контроллер - Login
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;
import javax.servlet.http.HttpSession;
import java.io.IOException;
@Controller
@SessionAttributes("session")
public class LoginController extends GlobalController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public String indexAction() throws IOException {
return "login";
}
@RequestMapping(value = "/", method= RequestMethod.POST)
public String indexAction(@RequestParam String username, @RequestParam String password,HttpSession session) {
String page = "login";
if(username != "" && password != ""){
try {
if(userService.authenticationUser(username,password) == "success"){
page = "redirect:/main";
session.setAttribute("test","Salom");
//this.httpSession =session;
//System.out.println(session.getAttribute("test"));
}
else page = "login";
}
catch (Exception e){
e.fillInStackTrace();
}
}
else page = "login";
return page;
}
}
Мой второй контроллер - Test
package com.springboot.app.controllers.reports;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.SessionAttributes;
import javax.servlet.http.HttpSession;
@SessionAttributes("session")
public class TestController {
@RequestMapping(value = "/test",method = RequestMethod.GET)
public String index(){
@SessionAttributes("session")HttpSession session;
return "";
}
}
---------------------------------------------------------------------------- Как передать @SessionAttributes ("сеанс") из контроллера входа в систему в контроллер тестирования или как сохранить @SessionAttributes ("сеанс"") в переменной