0
I have a Credential class that I use to store session user information (it’s annotated with @Sessionscope and @Component). When I print some attribute of this class, it usually appears, but if I try to use it in a jsp using JSTL, the session attribute is not found. What is the correct way to set up this session attribute?
Credential Class
@SessionScope
@Component
public class Credencial implements Serializable{
private String codigoFuncional;
private String nome;
private int juncao;
private String nomeJuncao;
private boolean ativo;
private List<Perfil> perfil;
private boolean primeiroAcesso;
//construtor e getters & setters
}
Controller class ```java @Controller @Requestmapping(value="/") public class Credelcontroller {
@Autowired
private Credencial credencial;
@PostMapping(value="/validarLogin/")
public RedirectView efetuarLogin(RedirectAttributes atributos, @Valid @ModelAttribute("credencialDto") CredencialDTO credencialDto, BindingResult resultado, ModelMap modelo){
System.out.println(credencial.getCodigoFuncional()); //essa linha funciona
}
```
But when I put the following line in the JSP, it doesn’t seem to find the attribute.
<c:out value="${sessionScope.credencial}" />
Is there any configuration missing to work? what am I doing wrong?