在构建演示应用程序时,我在登录和下一个主页时使用了 JSP。在 Authenticator 的“authenticate”功能之后,将“principal”对象返回到 JSP 主页。 我用过these tags to fetch 。现在,通过此获取变得变得复杂,因为它不支持 JSTL 或 Anugular。所以我需要知道身份验证完成后如何将主体对象转换为 JSON。请帮我解决这个问题。
最佳答案
导入com.fasterxml.jackson.databind.ObjectMapper;
ObjectMapper mapper = new ObjectMapper();
String user = mapper.writeValueAsString(principal);
System.out.println(user);
关于java - Spring Security 中 JSON 的主要对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33806395/