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

三联网站建设价格自己怎么设计公司前台设计效果图

三联网站建设价格,自己怎么设计公司前台设计效果图,网站建设中常见的问题,wordpress获取位置在Spring Cloud封装的Feign中并不直接支持传文件#xff0c;但可以通过引入Feign的扩展包来实现#xff0c;本来就来具体说说如何实现。 服务提供方#xff08;接收文件#xff09; 服务提供方的实现比较简单#xff0c;就按Spring MVC的正常实现方式即可#xff0c;比…在Spring Cloud封装的Feign中并不直接支持传文件但可以通过引入Feign的扩展包来实现本来就来具体说说如何实现。 服务提供方接收文件 服务提供方的实现比较简单就按Spring MVC的正常实现方式即可比如 EnableFeignClientsEnableDiscoveryClientSpringBootApplicationpublic class Application { RestController public class UploadController { PostMapping(value /uploadFile, consumes MediaType.MULTIPART_FORM_DATA_VALUE) public String handleFileUpload(RequestPart(value file) MultipartFile file) { return file.getName(); } } public static void main(String[] args) { new SpringApplicationBuilder(Application.class).web(true).run(args); }}服务消费方发送文件 在服务消费方由于会使用Feign客户端所以在这里需要在引入feign对表单提交的依赖具体如下 dependency groupIdio.github.openfeign.form/groupId artifactIdfeign-form/artifactId version3.0.3/version/dependencydependency groupIdio.github.openfeign.form/groupId artifactIdfeign-form-spring/artifactId version3.0.3/version/dependencydependency groupIdcommons-fileupload/groupId artifactIdcommons-fileupload/artifactId version1.3.3/version/dependency定义文件上传方的应用主类和FeignClient假设服务提供方的服务名为eureka-feign-upload-server EnableFeignClientsEnableDiscoveryClientSpringBootApplicationpublic class Application { public static void main(String[] args) { new SpringApplicationBuilder(Application.class).web(true).run(args); }}FeignClient(value upload-server, configuration UploadService.MultipartSupportConfig.class)public interface UploadService { PostMapping(value /uploadFile, consumes MediaType.MULTIPART_FORM_DATA_VALUE) String handleFileUpload(RequestPart(value file) MultipartFile file); Configuration class MultipartSupportConfig { Bean public Encoder feignFormEncoder() { return new SpringFormEncoder(); } } }在启动了服务提供方之后尝试在服务消费方编写测试用例来通过上面定义的Feign客户端来传文件比如 Slf4jRunWith(SpringJUnit4ClassRunner.class)SpringBootTestpublic class UploadTester { Autowired private UploadService uploadService; Test SneakyThrows public void testHandleFileUpload() { File file new File(upload.txt); DiskFileItem fileItem (DiskFileItem) new DiskFileItemFactory().createItem(file, MediaType.TEXT_PLAIN_VALUE, true, file.getName()); try (InputStream input new FileInputStream(file); OutputStream os fileItem.getOutputStream()) { IOUtils.copy(input, os); } catch (Exception e) { throw new IllegalArgumentException(Invalid file: e, e); } MultipartFile multi new CommonsMultipartFile(fileItem); log.info(uploadService.handleFileUpload(multi)); }}完整示例 读者可以根据喜好选择下面的两个仓库中查看eureka-feign-upload-server和eureka-feign-upload-client两个项目 Githubhttps://github.com/dyc87112/SpringCloud-Learning/Giteehttps://gitee.com/didispace/SpringCloud-Learning/ 如果您对这些感兴趣欢迎star、follow、收藏、转发给予支持
http://www.pierceye.com/news/913011/

相关文章:

  • 常州市建设工程质量监督站网站开发公司设计管理岗位述职
  • 国外网站顶部菜单设计谷歌seo文章
  • 梅州网站开发外国自适应企业网站
  • 大型网站建设动力无限哪个公司的装饰设计公司
  • 网站建设与管理自考wordpress替换默认的编辑器
  • 企业在网站推广咸阳做网站开发公司
  • 从美洲开始做皇帝免费阅读网站wordpress嵌入优酷视频播放
  • 长沙 外贸网站建设国际足联世界排名
  • 辽宁省建设执业继续教育协会网站深圳网站制作建设服务公司
  • 个人网站备案都需要什么运营seo是什么意思
  • 局域网内部网站建设app下载苏州网络推广企业
  • 重庆美邦 网站建设保定最新消息发布
  • 东莞手机建网站旅游网站 分析
  • 网站seo优化技术入门做网站怎样实现网上支付
  • 陕西西安网站建设公司源码编程器
  • 网站开发的前端技术有哪些软件制作是什么专业
  • 淘宝网站建设目标是什么意思厦门seo计费
  • 高端网站建设注意简述网络营销的基本方法
  • html5网站开发实例教程沈阳软件定制开发公司
  • 做透水砖的网站下载爱南宁乘车
  • 免费建设工程信息网站许昌市建设路小学网站
  • 网站建设公司华网天如何设置自己的网址
  • 株洲做网站那家好黑龙江网站设计
  • 培训视频网站百度权重划分等级
  • 重庆江北区网站建设怎么查询网站建设时间
  • 做网站一个月能挣多少怎么做营销推广
  • 网站做镜像检查漏洞网站建设需要哪些步骤
  • 广州手机建设网站wordpress 读者墙
  • 大桥石化集团网站谁做的wordpress建站吗
  • 手机行业网站做网站用什么环境