Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jgjy
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
注册表
注册表
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
svn
jgjy
Commits
5753efa4
提交
5753efa4
authored
4月 28, 2019
作者:
lvwei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
上级
e9972561
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
0 行增加
和
98 行删除
+0
-98
WebAppConfig.java
...r/src/main/java/com/zrqx/commons/config/WebAppConfig.java
+0
-98
没有找到文件。
com.zrqx.fg.member/src/main/java/com/zrqx/commons/config/WebAppConfig.java
deleted
100644 → 0
浏览文件 @
e9972561
package
com
.
zrqx
.
commons
.
config
;
import
java.nio.charset.Charset
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.convert.converter.Converter
;
import
org.springframework.format.support.FormattingConversionServiceFactoryBean
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
org.springframework.web.bind.support.ConfigurableWebBindingInitializer
;
import
org.springframework.web.servlet.config.annotation.CorsRegistry
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
com.alibaba.fastjson.support.config.FastJsonConfig
;
import
com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter
;
import
com.zrqx.commons.convert.StringToDateConverter
;
import
com.zrqx.core.commons.interceptor.InterceptorConfig
;
import
com.zrqx.core.constant.sysuser.SysUserRequestPath
;
/**
* 使用CustomWebMvcConfigurationSupport来显对 mvc的配置
* @author lpf
* @date 2018年7月24日下午8:01:05
*/
@Configuration
public
class
WebAppConfig
extends
WebMvcConfigurerAdapter
{
/**
* 跨域支持
*/
@Override
public
void
addCorsMappings
(
CorsRegistry
registry
)
{
registry
.
addMapping
(
"/**"
).
allowedOrigins
(
"*"
).
allowedMethods
(
"*"
).
allowCredentials
(
true
).
maxAge
(
3600
);
}
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
// 注册自定义拦截器,添加拦截路径和排除拦截路径
registry
.
addInterceptor
(
new
InterceptorConfig
()).
addPathPatterns
(
SysUserRequestPath
.
BG
+
"/**"
)
.
excludePathPatterns
(
SysUserRequestPath
.
BG
+
SysUserRequestPath
.
PERMISSIONS
+
SysUserRequestPath
.
LOGIN
);
}
@Override
public
void
configureMessageConverters
(
List
<
HttpMessageConverter
<?>>
converters
)
{
converters
.
add
(
fastJsonHttpMessageConverter
());
super
.
configureMessageConverters
(
converters
);
}
@Bean
public
HttpMessageConverter
<
Object
>
fastJsonHttpMessageConverter
(){
// fastjson 转换器
FastJsonHttpMessageConverter
fast
=
new
FastJsonHttpMessageConverter
();
// fastjson 配置
FastJsonConfig
fastJsonConfig
=
new
FastJsonConfig
();
fastJsonConfig
.
setDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
fastJsonConfig
.
setCharset
(
Charset
.
forName
(
"UTF-8"
));
fastJsonConfig
.
setSerializerFeatures
(
SerializerFeature
.
WriteMapNullValue
,
SerializerFeature
.
WriteDateUseDateFormat
,
SerializerFeature
.
QuoteFieldNames
);
fast
.
setFastJsonConfig
(
fastJsonConfig
);
// fastJson 支持解析类型
List
<
MediaType
>
list
=
new
ArrayList
<
MediaType
>();
list
.
add
(
MediaType
.
APPLICATION_JSON_UTF8
);
fast
.
setSupportedMediaTypes
(
list
);
return
fast
;
}
@Bean
public
Converter
<
String
,
Date
>
stringToDateConverter
()
{
StringToDateConverter
conver
=
new
StringToDateConverter
();
return
conver
;
}
@Bean
public
FormattingConversionServiceFactoryBean
conversionService
()
{
FormattingConversionServiceFactoryBean
bean
=
new
FormattingConversionServiceFactoryBean
();
Set
<
Converter
<?,
?>>
set
=
new
HashSet
<
Converter
<?,
?>>();
set
.
add
(
stringToDateConverter
());
bean
.
setConverters
(
set
);
return
bean
;
}
public
ConfigurableWebBindingInitializer
webBindingInitializer
(
@Autowired
ConfigurableWebBindingInitializer
config
)
{
config
.
setConversionService
(
conversionService
().
getObject
());
return
config
;
}
}
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论