(window.webpackJsonp=window.webpackJsonp||[]).push([[625],{1056:function(e,t,r){"use strict";r.r(t);var n=r(56),a=Object(n.a)({},(function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[r("h1",{attrs:{id:"jackson支助"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#jackson支助"}},[e._v("#")]),e._v(" Jackson支助")]),e._v(" "),r("p",[e._v("Spring 安全性为持久化 Spring 与安全性相关的类提供了Jackson支持。这可以在使用分布式会话(即会话复制、 Spring 会话等)时提高序列化 Spring 安全相关类的性能。")]),e._v(" "),r("p",[e._v("要使用它,将"),r("code",[e._v("SecurityJackson2Modules.getModules(ClassLoader)")]),e._v("注册为"),r("code",[e._v("ObjectMapper")]),e._v("("),r("a",{attrs:{href:"https://github.com/FasterXML/jackson-databind",target:"_blank",rel:"noopener noreferrer"}},[e._v("Jackson-数据库"),r("OutboundLink")],1),e._v("):")]),e._v(" "),r("div",{staticClass:"language- extra-class"},[r("pre",{pre:!0,attrs:{class:"language-text"}},[r("code",[e._v("ObjectMapper mapper = new ObjectMapper();\nClassLoader loader = getClass().getClassLoader();\nList modules = SecurityJackson2Modules.getModules(loader);\nmapper.registerModules(modules);\n\n// ... use ObjectMapper as normally ...\nSecurityContext context = new SecurityContextImpl();\n// ...\nString json = mapper.writeValueAsString(context);\n")])])]),r("table",[r("thead",[r("tr",[r("th"),e._v(" "),r("th",[e._v("以下 Spring 安全模块提供了Jackson支持:"),r("br"),r("br"),e._v("* Spring-security-core("),r("code",[e._v("CoreJackson2Module")]),e._v(")"),r("br"),r("br"),e._v("* Spring-security-web("),r("code",[e._v("WebJackson2Module")]),e._v(","),r("code",[e._v("WebServletJackson2Module")]),e._v(","),r("code",[e._v("WebServerJackson2Module")]),e._v(")"),r("br"),e._v('(<11"gt="9"/>r=“r=”/>(<18"r="19"r=">>>>>(<<<<>>>>>')])])]),e._v(" "),r("tbody")]),e._v(" "),r("p",[r("RouterLink",{attrs:{to:"/spring-security/concurrency.html"}},[e._v("并发性")]),r("RouterLink",{attrs:{to:"/spring-security/localization.html"}},[e._v("本地化")])],1)])}),[],!1,null,null,null);t.default=a.exports}}]);