<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)論排行榜

    主站蜘蛛池模板: 亚洲乱码中文字幕小综合| 亚洲国产精品无码中文字| 亚洲人成影院77777| 久久精品毛片免费观看| 亚洲人成在线观看| 99久久99久久精品免费观看 | 成人免费视频国产| 亚洲日韩国产二区无码| 国产小视频在线观看免费| 亚洲精华国产精华精华液| 国产成人免费片在线视频观看| 国产亚洲精品AAAA片APP| 免费国产不卡午夜福在线| 免费无码婬片aaa直播表情| 亚洲综合色视频在线观看| 中文字幕手机在线免费看电影| 亚洲午夜久久久久久久久久| a级毛片无码免费真人久久| 亚洲视频中文字幕| 很黄很色很刺激的视频免费| 亚洲国产午夜精品理论片在线播放 | 一本色道久久综合亚洲精品| 污污网站免费观看| 亚洲人配人种jizz| 亚洲国产天堂久久综合| 久久九九AV免费精品| 精品国产成人亚洲午夜福利| 免费人成网站在线高清| 可以免费观看的毛片| 亚洲人成小说网站色| 国产偷窥女洗浴在线观看亚洲| 久久国产乱子伦精品免费不卡 | 亚洲fuli在线观看| 免费国产在线观看老王影院| 久久久精品免费视频| 亚洲乱码在线观看| 亚洲午夜无码久久久久| 免费观看黄网站在线播放| 久久久精品视频免费观看| 亚洲一区二区三区播放在线 | 久久精品亚洲男人的天堂|