<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    java學(xué)習(xí)

    java學(xué)習(xí)

     

    在springboot中fastjson的配置

    第一種配置方法:
    在實(shí)體類中加入格式化屬性的注解
    public class User implements Serializable{
    /**
    */
    private static final long serialVersionUID = 1L;
    private Integer id;
    private String username;
    private Date birthday;
    private Integer age;
    public Integer getId() {
    return id;
    }
    public void setId(Integer id) {
    this.id = id;
    }
    @JSONField(format="yyyy-MM-dd hh:MM:ss")
    public Date getBirthday() {
    return birthday;
    }
    public void setBirthday(Date birthday) {
    this.birthday = birthday;
    }
    public String getUsername() {
    return username;
    }
    public void setUsername(String username) {
    this.username = username;
    }
    public Integer getAge() {
    return age;
    }
    public void setAge(Integer age) {
    this.age = age;
    }
    2.在啟動(dòng)類中繼承類
    @SpringBootApplication
    public class Demo1Application2 extends WebMvcConfigurerAdapter{
    @Override
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    super.configureMessageConverters(converters);
    FastJsonHttpMessageConverter fastConverter=new  FastJsonHttpMessageConverter();
    FastJsonConfig fastJsonConfig = new FastJsonConfig();
    fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
    fastConverter.setFastJsonConfig(fastJsonConfig);
    converters.add(fastConverter);
    }
    public static void main(String[] args) {
    SpringApplication app=new SpringApplication(Demo1Application2.class);
    ConfigurableApplicationContext context = app.run( args);
    //context.close();
    }
    }
    3.訪問(wèn)頁(yè)面,請(qǐng)求方法,得到結(jié)果
    { "age":11, "birthday":"2018-03-15 10:03:55", "id":1, "username":"dddd" }
    第二種配置方法:
    在啟動(dòng)類加入一個(gè)bean
    @SpringBootApplication
    public class Demo1Application3 {
    @Bean
    public HttpMessageConverters fastJsonHttpMessageConverters() {
    FastJsonHttpMessageConverter fastConverter=new  FastJsonHttpMessageConverter();
    FastJsonConfig fastJsonConfig = new FastJsonConfig();
    fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
    fastConverter.setFastJsonConfig(fastJsonConfig);
    HttpMessageConverter<?> converters=fastConverter;
    return new HttpMessageConverters(converters);
    }
    public static void main(String[] args) {
    SpringApplication app=new SpringApplication(Demo1Application3.class);
    ConfigurableApplicationContext context = app.run( args);
    //context.close();
    }
    }

    posted on 2018-03-15 10:36 楊軍威 閱讀(1184) 評(píng)論(0)  編輯  收藏


    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     

    導(dǎo)航

    統(tǒng)計(jì)

    常用鏈接

    留言簿

    隨筆檔案

    搜索

    最新評(píng)論

    閱讀排行榜

    評(píng)論排行榜

    主站蜘蛛池模板: 亚洲热线99精品视频| 亚洲精品午夜国产VA久久成人| 亚洲丝袜美腿视频| 一级毛片免费播放男男| 亚洲伊人色欲综合网| 97人妻精品全国免费视频| 亚洲福利视频一区| 亚洲毛片在线免费观看| 亚洲人成网男女大片在线播放| 国产v精品成人免费视频400条| 亚洲欧美日韩国产精品一区| 四虎永久在线精品免费影视| www免费插插视频| 亚洲国产人成在线观看69网站 | 一本天堂ⅴ无码亚洲道久久| 日韩免费无砖专区2020狼| 欧亚一级毛片免费看| 亚洲AV午夜福利精品一区二区| 中文字幕乱码免费视频| 亚洲AV无码一区二区三区电影 | 一级做a爰片性色毛片免费网站| 久久精品国产亚洲av水果派| www.亚洲精品| 一个人看www在线高清免费看| 国产做国产爱免费视频| 亚洲成av人片在线天堂无| 亚洲AV成人片色在线观看| yy6080亚洲一级理论| 久久精品a一国产成人免费网站| 你好老叔电影观看免费| 看一级毛片免费观看视频| 亚洲国产精品专区| 亚洲成色WWW久久网站| 亚洲国产电影av在线网址| 99热在线精品免费全部my| 无码人妻丰满熟妇区免费| 一个人看的www在线免费视频 | 激情五月亚洲色图| 亚洲精品美女久久久久| 国产亚洲一区二区在线观看| 免费大香伊蕉在人线国产|