【转】Attachment support&nb…

Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled解决方案

错误原因:  
需要mail.jar和activation.jar。

Solution:  
Web Services Required Jars Download Instructions  
http://www.eclipse.org/webtools/wst/components/ws/download_instructions_for_jars.html

解决办法:  
1) 下载javamail和jaf,解压出mail.jar和activation.jar  
http://java.sun.com/products/javamail/downloads/index.html  
http://java.sun.com/products/javabeans/glasgow/jaf.html#download  

2) 把mail.jar和activation.jar放到%AXIS_HOME%\WEB-INF\lib目录下  
3) 将.jar文件添加到%CLASSPATH%  
说明:  
这个是可以忽略的。不过以后构建web services都要用到的,还是添加上的好。  
参考: http://www.ogsadai.org.uk/documentation/ogsadai-wsi-2.1/doc/wsi/FAQ.html  
This is a warning message that can safely be ignored. It is displayed when Axis has been deployed without an optional JAR. An optional JAR is one that allows Axis to support a particular piece of functionalty but is not required for general use. Please refer to the Axis documentation for more details.

备注:  
一篇很好的jars下载指南:  
Web Services Required Jars Download Instructions

Axis指南:  
Guide to building Axis

在CSDN开发的"C知道"中,我可以为您介绍如何将attachment文件换为MultipartFile对象。 要将attachment文件换为MultipartFile对象,您可以按照以下步骤进行操作: 1. 首先,您需要获取attachment文件的字节数据。这可以通过读取文件的方式来实现。您可以使用Java中的FileInputStream或者其他相关的文件读取类来读取文件的字节数据。 2. 接下来,您需要创建一个MultipartFile对象。MultipartFile是Spring框架提供的接口,用于表示上传的文件。您可以使用MockMultipartFile类来创建MultipartFile对象。 3. 使用MockMultipartFile的构造函数来创建MultipartFile对象。构造函数需要传入以下参数: - 文件名:可以从attachment文件中获取。 - 字节数据:从attachment文件中读取的字节数据。 - 文件类型:可以从attachment文件中获取。 4. 最后,您可以将创建的MultipartFile对象用于后续的操作,例如上传到服务器等。 下面是一个示例代码,展示了如何将attachment文件换为MultipartFile对象: ```java import org.springframework.mock.web.MockMultipartFile; import org.springframework.web.multipart.MultipartFile; import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class AttachmentConverter { public MultipartFile convertToMultipartFile(File attachment) throws IOException { // 读取attachment文件的字节数据 FileInputStream fileInputStream = new FileInputStream(attachment); byte[] bytes = new byte[(int) attachment.length()]; fileInputStream.read(bytes); fileInputStream.close(); // 创建MultipartFile对象 MultipartFile multipartFile = new MockMultipartFile( attachment.getName(), attachment.getName(), "application/octet-stream", bytes ); return multipartFile; } } ``` 请注意,上述示例代码中使用的是Spring框架提供的MockMultipartFile类。如果您没有使用Spring框架,您可以根据自己的需求选择适合的方式来创建MultipartFile对象。 希望以上信息能够帮助到您!如果您有任何进一步的问题,请随时提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值