ResponseBody和文件上传

不羁岁月 提交于 2019-12-02 03:01:23

SpringMVC默认使用MappingJacksonHttpMessageConverter对json数据进行转换

<dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.9.0</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>2.9.0</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-annotations</artifactId>
      <version>2.9.0</version>
    </dependency>

 

使用@ResponseBody注解实现将Controller方法返回对象转换json响应给客户端。

 

文件上传

第一种方式:使用commons-fileupload组件实现文件上传,需要用到commons-fileupload和commons-io

第二种方式:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!