当前位置: 首页 > news >正文

专业网站快速排名优势班级优化大师电脑版

专业网站快速排名优势,班级优化大师电脑版,兼职网站做任务,建一个购物网站需要多少钱用JAVA进行编写WEB项目时,我们一般需要对WEB进行统一配置,例如制定拦截路径、页面解析器、跨域配置、fastjson报文解析、文件上传大小配置等。 Getter Setter Configuration public class WebConfiguration extends WebMvcConfigurationSupport {priva…

用JAVA进行编写WEB项目时,我们一般需要对WEB进行统一配置,例如制定拦截路径、页面解析器、跨域配置、fastjson报文解析、文件上传大小配置等。

@Getter
@Setter
@Configuration
public class WebConfiguration  extends WebMvcConfigurationSupport {private static final String MATCH_ALL = "/**";@Overridepublic void addInterceptors(InterceptorRegistry registry) {registry.addInterceptor(new RequestIdInterceptor()).addPathPatterns(MATCH_ALL);registry.addInterceptor(new MockRequestEntityInterceptor()).addPathPatterns(MATCH_ALL);}@Overridepublic void addViewControllers(ViewControllerRegistry registry) {registry.addViewController("/").setViewName("index");registry.setOrder(Ordered.HIGHEST_PRECEDENCE);super.addViewControllers(registry);}/** Spring mvc 的页面解析器配置*/@Beanpublic InternalResourceViewResolver viewResolver(){InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();viewResolver.setPrefix("/");viewResolver.setSuffix(".html");return viewResolver;}/*** 跨域配置*/public CorsFilter corsFilter() {UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();source.registerCorsConfiguration("/**", corsConfig());return new CorsFilter(source);}/** Spring mvc 的静态资源路径配置*/@Overridepublic void addResourceHandlers(ResourceHandlerRegistry registry) {registry.addResourceHandler("/resource/**").addResourceLocations("classpath:/static/resource/");registry.addResourceHandler("/*.html").addResourceLocations("classpath:/static/");}/** 项目序列化使用fastjson,因序列化解析器执行是列表由前至后的优先级,故把fastjson加入到序列0的位置*/@Overridepublic void extendMessageConverters(List<HttpMessageConverter<?>> converters) {converters.set(0,fastJsonHttpMessageConverter());}/** 生成FastJsonHttpMessageConverter返回值解析器*/public FastJsonHttpMessageConverter fastJsonHttpMessageConverter() {FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();converter.setFastJsonConfig(fastJsonConfig());converter.setSupportedMediaTypes(mediaTypes());return converter;}/** 生成FastJsonHttpMessageConverter返回值解析器 - 解析详细配置*/public FastJsonConfig fastJsonConfig() {FastJsonConfig fastJsonConfig = new FastJsonConfig();fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat,SerializerFeature.WriteEnumUsingToString);// 日期时间格式及字符集配置fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");fastJsonConfig.setCharset(Charset.forName("utf-8"));// 防止Long类型转json丢失精度的问题SerializeConfig serializeConfig = SerializeConfig.globalInstance;serializeConfig.put(Long.class, ToStringSerializer.instance);serializeConfig.put(Long.TYPE, ToStringSerializer.instance);fastJsonConfig.setSerializeConfig(serializeConfig);return fastJsonConfig;}/** 生成FastJsonHttpMessageConverter返回值解析器 - 解析格式组件 支持的mediaType的类型* 1.application/json;charset=UTF-8* 2.application/json*/public List<MediaType> mediaTypes() {List<MediaType> mediaTypeList = new ArrayList<>();mediaTypeList.add(MediaType.APPLICATION_JSON_UTF8);mediaTypeList.add(MediaType.APPLICATION_JSON);return mediaTypeList;}@Beanpublic CommonsMultipartResolver multipartResolver() {CommonsMultipartResolver resolver = new CommonsMultipartResolver();resolver.setDefaultEncoding("UTF-8");//resolveLazily属性启用是为了推迟文件解析,以在在UploadAction中捕获文件大小异常resolver.setResolveLazily(true);resolver.setMaxInMemorySize(40960);//上传文件大小 5M 5*1024*1024resolver.setMaxUploadSize(5 * 1024 * 1024);return resolver;}private CorsConfiguration corsConfig() {CorsConfiguration corsConfiguration = new CorsConfiguration();corsConfiguration.addAllowedOrigin("*");corsConfiguration.addAllowedHeader("*");corsConfiguration.addAllowedMethod("*");corsConfiguration.setAllowCredentials(true);corsConfiguration.setMaxAge(3600L);return corsConfiguration;}
}

http://www.15wanjia.com/news/40627.html

相关文章:

  • 政府网站是哪个建设的网络推广培训去哪里好
  • 清远网站关键词优化网络营销服务公司
  • 网站建设认知与理解seo综合查询工具下载
  • 中文网址和中文域名区别衡水seo营销
  • 六一儿童节网站制作外贸网站有哪些
  • 重庆专业网站推广流程十大广告投放平台
  • 全网最稳最低价自助下单网站网络舆情监测
  • 洛阳网站建设培训泰安百度推广代理商
  • 专做农产品跨境的网站有营销渠道模式有哪些
  • 网站建设犀牛云免费网站统计代码
  • 手机制作网站软件下载编程培训机构排名前十
  • html网站怎么做视频教程seo课程心得体会
  • 江苏天目建设网站网站页面怎么优化
  • 山东网站建设价格实惠seo推广有哪些公司
  • 抚州建设网站的公司山东seo推广
  • 为何建设银行网站无法登陆小红书推广运营
  • 网站建设开发模式h5石家庄百度关键词搜索
  • ppt汇报模板下载无线网络优化工程师
  • asp网站模版安装灰色行业怎么推广引流
  • 关于做旅游网站的参考文献灰色关键词代发可测试
  • 公司网站是否做地方分站大数据营销推广精准粉
  • 罗湖网站建设的公司培训机构管理系统
  • 深圳工厂网站建设公司沈阳网站关键词排名
  • 做搜狗pc网站优化首哪个平台视频资源多
  • 搜索引擎站长平台企业培训课程表
  • 兰州网站建设公司武汉百度推广入口
  • 重庆哪家做网站好数据交换平台
  • 电子商务网站进度的基本流程seo运营经理
  • 建设心理网站seo中文意思是
  • WordPress最强大的主题济南seo小黑seo