1. 处理 JSON

1. 主要步骤

  1. 加入 jar 包
  2. 编写目标方法,使其返回 JSON 对应的对象或集合
  3. 在方法上添加 @ReponseBody 注解

2. 具体实现

1. 在 SpringMVCTest 中加入

@ResponseBody
	@RequestMapping("/testJson")
	public Collection<Employee> testJson(){
		return employeeDao.getAll();
	}

2. 视图 index.jsp 中加入

<a href="testJson" id="testJson">Test Json</a>
	<br><br>

2. HttpMessageConverter 原理图

SpringMVC 学习笔记(九)- 处理 JSON:使用 HttpMessageConverter

相关文章:

  • 2021-10-28
  • 2021-05-11
  • 2021-07-09
  • 2021-05-12
  • 2023-02-16
  • 2021-12-10
  • 2021-09-14
  • 2021-12-26
猜你喜欢
  • 2021-09-27
  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
  • 2021-05-21
  • 2021-12-11
  • 2021-06-12
相关资源
相似解决方案