简体   繁体   中英

Principal Object to JSON in Spring Security

While building a Demo app I used JSP while login and next home page. After "authenticate" function of Authenticator returns "principal" object to home JSP page. I used these tags to fetch . Now this is becoming complex to fetch through this, as it wont support JSTL or Anugular. So I need to know how can I convert Principal object to JSON after Authentication is done. Please help me on this.

import com.fasterxml.jackson.databind.ObjectMapper;

    ObjectMapper mapper = new ObjectMapper();
    String user = mapper.writeValueAsString(principal);
    System.out.println(user);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM