小编Nik*_*han的帖子

将String转换为Spring资源的方法

我有一个类在Spring(org.springframework.core.io.Resource)中具有Resource类型的资源属性,它将文件对象作为输入.

setResource(Resource resource) 
  {
     this.resource = resource;
  }
Run Code Online (Sandbox Code Playgroud)

但是,我正在通过另一个自定义API读取远程文档,该API将文档的内容作为String返回.

String xml = document.getContent();
Run Code Online (Sandbox Code Playgroud)

我想像Resource我的setResource方法一样传递这个xml .但是,我不知道如何将String转换为Resource.

有任何想法吗 ??

string resources spring

8
推荐指数
1
解决办法
9866
查看次数

标签 统计

resources ×1

spring ×1

string ×1