【发布时间】:2015-08-09 06:25:32
【问题描述】:
我在Spring JSONmessageConverter看到了如下评论:
/**
* Indicate whether the JSON output by this view should be prefixed with "{} &&". Default is false.
* <p>Prefixing the JSON string in this manner is used to help prevent JSON Hijacking.
* The prefix renders the string syntactically invalid as a script so that it cannot be hijacked.
* This prefix does not affect the evaluation of JSON, but if JSON validation is performed on the
* string, the prefix would need to be ignored.
*/
字符串前缀如何防止 JSON 劫持?
【问题讨论】:
-
太好了,我不知道 Spring 支持这个。你能分享一下这个评论在哪个类和包中吗?
-
@Sanjay 它是
org.springframework.http.converter.json.MappingJackson2HttpMessageConverter- 请参阅setPrefixJson()方法
标签: java json spring security web