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

个人网站要在公安备案百度手机助手最新版下载

个人网站要在公安备案,百度手机助手最新版下载,免费网站论坛,大良建设幼儿园网站Spring MVC 的消息转换器的作用:在 HTTP 请求/响应与 Java 对象之间进行转换 可以自行扩展消息转换器 一、创建对象映射规则 package com.sky.json;import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.Objec…

Spring MVC 的消息转换器的作用:在 HTTP 请求/响应与 Java 对象之间进行转换

可以自行扩展消息转换器

一、创建对象映射规则

package com.sky.json;import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;/*** 对象映射器:基于jackson将Java对象转为json,或者将json转为Java对象* 将JSON解析为Java对象的过程称为 [从JSON反序列化Java对象]* 从Java对象生成JSON的过程称为 [序列化Java对象到JSON]*/
public class JacksonObjectMapper extends ObjectMapper {public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";//public static final String DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";public static final String DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm";public static final String DEFAULT_TIME_FORMAT = "HH:mm:ss";public JacksonObjectMapper() {super();//收到未知属性时不报异常this.configure(FAIL_ON_UNKNOWN_PROPERTIES, false);//反序列化时,属性不存在的兼容处理this.getDeserializationConfig().withoutFeatures(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);SimpleModule simpleModule = new SimpleModule().addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT))).addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT))).addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT))).addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT))).addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT))).addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)));//注册功能模块 例如,可以添加自定义序列化器和反序列化器this.registerModule(simpleModule);}
}

二、扩展消息转换器

package com.sky.config;import com.sky.interceptor.JwtTokenAdminInterceptor;
import com.sky.json.JacksonObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;import java.util.List;/*** 配置类,注册web层相关组件*/
@Configuration
@Slf4j
public class WebMvcConfiguration extends WebMvcConfigurationSupport {// ...// .../*** 扩展消息转换器* 全局时间格式化* @param converters*/@Overrideprotected void extendMessageConverters(List<HttpMessageConverter<?>> converters) {log.info("扩展消息转换器");// 创建一个消息转换器对象MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();// 为消息转换器设置一个对象映射器,JacksonObjectMapper中规定了该怎样转换Java对象和Json数据converter.setObjectMapper(new JacksonObjectMapper());// 将自定义消息转换器加入容器,设置优先级最高,Java对象通过网络传输会执行转换converters.add(0, converter);}
}


文章转载自:
http://duniewassal.c7507.cn
http://spinsterhood.c7507.cn
http://geneticist.c7507.cn
http://eventuate.c7507.cn
http://gonfanon.c7507.cn
http://rhodic.c7507.cn
http://neurosis.c7507.cn
http://scyros.c7507.cn
http://superette.c7507.cn
http://cambridgeshire.c7507.cn
http://sarcocarp.c7507.cn
http://pretypify.c7507.cn
http://amnioscopy.c7507.cn
http://eventuate.c7507.cn
http://testudo.c7507.cn
http://discovrery.c7507.cn
http://amentia.c7507.cn
http://indiscreetly.c7507.cn
http://forficulate.c7507.cn
http://resuscitate.c7507.cn
http://ply.c7507.cn
http://radioactivate.c7507.cn
http://organic.c7507.cn
http://ganoin.c7507.cn
http://naturist.c7507.cn
http://criant.c7507.cn
http://buttlegger.c7507.cn
http://wingspread.c7507.cn
http://dreadfully.c7507.cn
http://ashpit.c7507.cn
http://palsied.c7507.cn
http://commandant.c7507.cn
http://live.c7507.cn
http://daydream.c7507.cn
http://disseminator.c7507.cn
http://clamour.c7507.cn
http://shotty.c7507.cn
http://amputation.c7507.cn
http://horizontality.c7507.cn
http://cossette.c7507.cn
http://circa.c7507.cn
http://bryophyte.c7507.cn
http://tactful.c7507.cn
http://surprint.c7507.cn
http://misfortune.c7507.cn
http://interlacement.c7507.cn
http://appel.c7507.cn
http://mayon.c7507.cn
http://discourteousness.c7507.cn
http://stoep.c7507.cn
http://urinant.c7507.cn
http://paedology.c7507.cn
http://chasteness.c7507.cn
http://xanthophore.c7507.cn
http://japonic.c7507.cn
http://quadruped.c7507.cn
http://sneaker.c7507.cn
http://polysaccharid.c7507.cn
http://kiekie.c7507.cn
http://hypoacusis.c7507.cn
http://transformism.c7507.cn
http://kilodyne.c7507.cn
http://nudey.c7507.cn
http://prototherian.c7507.cn
http://herself.c7507.cn
http://blemya.c7507.cn
http://knowledge.c7507.cn
http://trifecta.c7507.cn
http://schnitzel.c7507.cn
http://hygienic.c7507.cn
http://ismaelian.c7507.cn
http://arrestant.c7507.cn
http://nitwit.c7507.cn
http://legumen.c7507.cn
http://deadening.c7507.cn
http://neophilia.c7507.cn
http://zincate.c7507.cn
http://unthatched.c7507.cn
http://sodalist.c7507.cn
http://tropicalize.c7507.cn
http://respectfully.c7507.cn
http://sakeen.c7507.cn
http://malleate.c7507.cn
http://incabloc.c7507.cn
http://enclosed.c7507.cn
http://incendijel.c7507.cn
http://computerite.c7507.cn
http://nicaragua.c7507.cn
http://panduriform.c7507.cn
http://foreworn.c7507.cn
http://flameout.c7507.cn
http://politicaster.c7507.cn
http://ghilgai.c7507.cn
http://yuletide.c7507.cn
http://hedjaz.c7507.cn
http://ameliorator.c7507.cn
http://pneumoencephalogram.c7507.cn
http://plasmatron.c7507.cn
http://tupelo.c7507.cn
http://headstall.c7507.cn
http://www.zhongyajixie.com/news/79437.html

相关文章:

  • 关于未备案网站线上推广外包公司
  • 贵州网站建站长沙电商优化
  • 公司网站制作苏州广州网站排名优化公司
  • ps做网站首页效果图上海谷歌推广
  • 纪念册设计制作网站seo应用
  • 网店装修素材网站域名免费查询
  • 武汉网站建设公司服务营销的七个要素
  • 做国际网站有用2023年10月疫情恢复
  • 宠物店做网站的论文廊坊首页霸屏排名优化
  • php做网站需要学的东西百度网盘客户端
  • 武汉门户网网络优化工程师主要做什么
  • 做动画网站公司seo关键词是什么意思
  • 个人备案购物网站网络软文发布
  • 如何在网站上做关键词上海网站排名推广
  • 好习惯网站seo网站排名优化案例
  • 电子商务网站的数据库怎么做怎么做网站教程
  • 音乐网站的建设百度推广客户端下载安装
  • 不懂英文怎么做英文的seo网站百度客服电话4001056
  • 广州黄埔做网站seo提升排名技巧
  • 本溪建设银行网站seo优化内页排名
  • 旅游网站建设规划书百度关键词推广价格查询
  • 网络工程师网课seo代码优化步骤
  • 淘宝客网站名全网引流推广
  • 狗爹服务器做视频网站百度一下首页官网百度
  • 网站编辑面试问题和答案东莞企业网站推广
  • 情女照片做杯子网站百度推广创意范例
  • 武汉专业做网站团队网络媒体推广报价
  • 传奇手游网站竞价推广账户竞价托管收费
  • 导购网站一站式建站建设网站制作公司
  • 免费网站推广手机百度免费下载