分享

no object DCH for MIME type Java教程,Java语言,电脑教...

 欢欢2008 2011-03-13

在用javamail编写邮件发送系统时,调试阶段没有任何问题,但在打成jar包的时候运行故障如下:

no object DCH for MIME type

后面我记不清了,意思好像是不支持MIME type=gbk或utf-8,废话少说,解决方法如下:

事实上这个是邮件发送时验证组件设置不当引起的,这个组件配置方法如下

(http://java./j2ee/1.4/docs/api/javax/activation/MailcapCommandMap.html)

The MailcapCommandMap looks in various places in the user’s system for mailcap file entries. When requests are made to search for commands in the MailcapCommandMap, it searches mailcap files in the following order:

1) Programatically added entries to the MailcapCommandMap instance.
2) The file .mailcap in the user’s home directory.
3) The file /lib/mailcap.
4) The file or resources named META-INF/mailcap.
5) The file or resource named META-INF/mailcap.default (usually found only in the activation.jar file).

我选用了第四种方法,在生成的Jar文件中加入了 META-INF/mailcap.

#
# This is a very simple ''mailcap'' file
#
image/gif;; x-java-view=com.sun.activation.viewers.ImageViewer
image/jpeg;; x-java-view=com.sun.activation.viewers.ImageViewer
text/*;; x-java-view=com.sun.activation.viewers.TextViewer
text/*;; x-java-edit=com.sun.activation.viewers.TextEditor
text/html;; x-java-content-handler=com.sun.mail.handlers.text_html
text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml
text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain
multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed
message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多