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

一个网站3个相似域名体验式营销案例

一个网站3个相似域名,体验式营销案例,网站1g的空间能用多久,wordpress 主页文件在 Spring Boot 3 中整合 FastJSON 2 主要涉及到以下几个步骤,包括添加依赖、配置 FastJSON 作为 JSON 处理器等。下面是详细的步骤: 1. 添加依赖 首先,你需要在你的 pom.xml 文件中添加 FastJSON 2 的依赖。以下是 Maven 依赖的示例&#…

在 Spring Boot 3 中整合 FastJSON 2 主要涉及到以下几个步骤,包括添加依赖、配置 FastJSON 作为 JSON 处理器等。下面是详细的步骤:

1. 添加依赖

首先,你需要在你的 pom.xml 文件中添加 FastJSON 2 的依赖。以下是 Maven 依赖的示例:

<!-- https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2-extension-spring6 -->
<dependency><groupId>com.alibaba.fastjson2</groupId><artifactId>fastjson2-extension-spring6</artifactId><version>2.0.53</version>
</dependency><!-- https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2 -->
<dependency><groupId>com.alibaba.fastjson2</groupId><artifactId>fastjson2</artifactId><version>2.0.53</version>
</dependency>

2. 配置 FastJSON 作为 JSON 处理器

在 Spring Boot 3 中,默认的 JSON 处理器是 Jackson。如果你想使用 FastJSON 作为 JSON 处理器,你需要创建一个配置类来注册 FastJSON 的 HttpMessageConverter

import com.alibaba.fastjson2.support.config.FastJsonConfig;
import com.alibaba.fastjson2.support.spring6.http.converter.FastJsonHttpMessageConverter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;@Slf4j
@Configuration
public class Fastjson2Config implements WebMvcConfigurer {/*** Fastjson2Config* @author <a href="https://zhengkai.blog.csdn.net/">zhengkai.blog.csdn.net</a>*/@Overridepublic void configureMessageConverters(List<HttpMessageConverter<?>> converters) {FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();FastJsonConfig config = new FastJsonConfig();config.setDateFormat("yyyy-MM-dd HH:mm:ss");// 其他配置...converter.setFastJsonConfig(config);converter.setDefaultCharset(StandardCharsets.UTF_8);converter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON));converters.add(0, converter);log.info("Fastjson2 Initial Done");}
}

3. 使用 FastJSON2 进行 JSON 序列化和反序列化

在你的 Spring Boot 应用中,你可以直接使用 FastJSON 的 API 进行 JSON 的序列化和反序列化。例如:

import com.alibaba.fastjson2.JSON;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
public class SampleController {@GetMapping("/json")public String getJson() {MyObject obj = new MyObject();obj.setName("Test");obj.setValue(123);// 使用 FastJSON 进行序列化return JSON.toJSONString(obj);}public static class MyObject {private String name;private int value;// Getter 和 Setterpublic String getName() {return name;}public void setName(String name) {this.name = name;}public int getValue() {return value;}public void setValue(int value) {this.value = value;}}
}

4. 测试

启动你的 Spring Boot 应用,并访问 /json 路径,你应该能够看到 FastJSON 生成的 JSON 响应。

http://www.wangmingla.cn/news/83542.html

相关文章:

  • 河南十大营销策划公司百度关键词优化怎么做
  • 河北高阳做网站的百度推广电话客服24小时
  • 做前端网站用什么软件写代码吗泰安百度推广代理
  • 做网站 徐州网站关键词怎么添加
  • 露天做愛偷拍网站搜索引擎公司排名
  • 男女做爰全过程网站查域名备案信息查询
  • 义乌 网站制作seo行业岗位
  • 怎么进行网站诊断百度帐号申请注册
  • 规范网站建设情况的报告百度开户多少钱
  • 凡科网的网站建设好用吗惠州seo怎么做
  • 装饰公司响应式网站建设案例网络推广平台都有哪些
  • wordpress 打不开主题seo教程有什么
  • wordpress 图片加水印插件志鸿优化设计答案网
  • 做网站交接什么时需要交接seo教程网
  • 苍南最好的网站建设公司网站外贸推广
  • 清浦网站建设网络推广是干什么的
  • 网站制作怎么入门中国培训网的证书含金量
  • go做后端的网站网络推广外包联系方式
  • 关于戒烟网站怎么做谷歌搜索引擎入口手机版
  • 网络促销方案北京seo优化技术
  • 适合当手机主页的网站个人网页设计作品欣赏
  • 网站建设如何做用户名密码seoul是啥意思
  • 山东做网站找哪家好济南竞价托管公司
  • 大良营销网站建设信息2345导航网址
  • 知名电子商务网站百度关键词优化查询
  • 网络工程师教程seo综合优化公司
  • 西部数码网站助手教程网络营销软件推广
  • 专门做英雄联盟h漫的外国网站调价智能关键词软件
  • 内蒙古政府网站建设 论文百度怎样发布信息
  • 清远疫情防控措施新乡seo推广