Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
c5337c73
Commit
c5337c73
authored
Aug 25, 2017
by
stylefeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
整理默认fastjson配置
parent
4e9d74bc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
guns-core/src/main/java/com/stylefeng/guns/core/config/DefaultFastjsonConfig.java
+18
-4
No files found.
guns-core/src/main/java/com/stylefeng/guns/core/config/FastjsonConfig.java
→
guns-core/src/main/java/com/stylefeng/guns/core/config/
Default
FastjsonConfig.java
View file @
c5337c73
...
...
@@ -13,6 +13,7 @@ import org.springframework.http.MediaType;
import
java.nio.charset.Charset
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* fastjson配置类
...
...
@@ -24,11 +25,20 @@ import java.util.ArrayList;
@ConditionalOnClass
(
com
.
alibaba
.
fastjson
.
JSON
.
class
)
@ConditionalOnMissingBean
(
FastJsonHttpMessageConverter4
.
class
)
@ConditionalOnWebApplication
public
class
FastjsonConfig
{
public
class
Default
FastjsonConfig
{
@Bean
public
FastJsonHttpMessageConverter4
fastJsonHttpMessageConverter
()
{
FastJsonHttpMessageConverter4
converter
=
new
FastJsonHttpMessageConverter4
();
converter
.
setFastJsonConfig
(
fastjsonConfig
());
converter
.
setSupportedMediaTypes
(
getSupportedMediaType
());
return
converter
;
}
/**
* fastjson的配置
*/
public
FastJsonConfig
fastjsonConfig
()
{
FastJsonConfig
fastJsonConfig
=
new
FastJsonConfig
();
fastJsonConfig
.
setSerializerFeatures
(
SerializerFeature
.
PrettyFormat
,
...
...
@@ -45,12 +55,16 @@ public class FastjsonConfig {
};
fastJsonConfig
.
setCharset
(
Charset
.
forName
(
"utf-8"
));
fastJsonConfig
.
setSerializeFilters
(
valueFilter
);
converter
.
setFastJsonConfig
(
fastJsonConfig
);
return
fastJsonConfig
;
}
/**
* 支持的mediaType类型
*/
private
List
<
MediaType
>
getSupportedMediaType
()
{
ArrayList
<
MediaType
>
mediaTypes
=
new
ArrayList
<>();
mediaTypes
.
add
(
MediaType
.
APPLICATION_JSON_UTF8
);
converter
.
setSupportedMediaTypes
(
mediaTypes
);
return
converter
;
return
mediaTypes
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment