Java Mail·¢ËÍ´øÓÐͼƬµÄhtml¸ñʽµÄÓʼþ
Java Mail·¢ËÍ´øÓÐͼƬµÄhtml¸ñʽµÄÓʼþ£¬Õë¶ÔÓÚÏÔʾͼƬ£¬Ò»°ãÓÐÁ½ÖÖ·½·¨¡£
1. ͼƬ´æÔÚÓÚ·þÎñÆ÷ÉÏ£¬ÎÒÃÇÖ»ÐèÒª°ÑͼƬÔÚ·þÎñÆ÷µÄµÄÁ´½Ó·Å½øÈ¥¼´¿É¡£
ÕâÖÖ·¢Ê½±È½Ï¼òµ¥£¬µ«ÊÇÕâÖÖ·½·¨ÓÐЩȱÏÝ£º
ͼƬ²»Ö§³ÖÀëÏßä¯ÀÀ£»
ÿ´Îä¯ÀÀÓʼþÐèÒª·ÃÎÊweb·þÎñ£¬Ôö¼Ó·þÎñÆ÷¸ºµ££»
ÈôͼƬÒÔ¶þ½øÖƵķ½Ê½´æÔÚÓÚÊý¾Ý¿â»òÊǶ¯Ì¬Éú³ÉµÄ£¬ÔòÎÞ·¨ÓÐЧµÄ½â¾ö¡£
2. °ÑͼƬÒÔ¸½¼þµÄ·½Ê½·¢ËͳöÈ¥£¬ÕâÖÖ·½Ê½·Ç³£ÊÊÓÃÓÚͼƬ´æÔÚÓÚÊý¾Ý¿âÖеÄÇé¿ö¡£
±¾ÎÄÒ²Ö÷ÒªÌÖÂÛÕâÖÖÇé¿ö¡£
¶ÔÓÚJava MailµÄ»ù´¡ÖªÊ¶£¬Çë¿´http://www.yesky.com/SoftChannel/72348977504190464/20020713/1620276.shtml£¬
±¾ÎIJ»×÷½éÉÜÁË¡£
˵µ½ÓʼþÖеĸ½¼þ£¬ÎÒ²»µÃ²»ËµÒ»ËµMiniMultipartÀ࣬ÌṩÁËÔÚÓʼþÖмÓÈ븽¼ÓµÄʵÏÖ·½·¨¡£
Ò»¸ö¶à²¿·ÖÓʼþÊÇÒ»¸öÄÚÈÝÀàÐÍ£¨content-type£©±»ÉèÖÃΪMiniMultipartµÄMessage¶ÔÏó¡£
MiniMultipartÀàÊÇÒ»¸öÈÝÆ÷À࣬°üº¬MimeBodyPartÀàÐ͵ĶÔÏó¡£
ÎÒÃÇ¿ÉÒÔÓÃÒ»¸öMimeBodyPart°üº¬htmlÔ´´úÂ룬ÆäËûµÄMimeBodyPart°üº¬¶þ½øÖƵÄͼƬ¸½¼þ¡£
µ«ÊÇÕâÀïÓиöÒâÍâÇé¿ö£¬ÎÒÃÇÏÈ¿´MimeBodyPartµÄ³õʼ»¯´úÂ룺
MimeBodyPart mdp = new MimeBodyPart(); //н¨Ò»¸ö´æ·Å¸½¼þµÄBodyPart
DataHandler dh = new DataHandler(...);
mdp.setDataHandler(dh); //¸øBodyPart¶ÔÏóÉèÖÃÄÚÈÝΪdh
ÆäÖе±DataHandler³õʼ»¯Ê±ÐèÒªDataSourceµÄ×ÓÀà
/** from JDK Doc */
public DataHandler(DataSource ds)
Create a DataHandler instance referencing the specified DataSource.
The data exists in a byte stream form. The DataSource will provide an InputStream to access the data.
Parameters:ds - the DataSource
ÔÚJDK1.4ÖУ¬DataSourceÊǸöInterface,DataSource½öÓÐMimePartDataSource, URLDataSource, FileDataSourceÈý¸ö×ÓÀ࣬
¶øÔÚÕâÈý¸öÀàÖÐûÓÐÒ»¸öÄÜÖ±½ÓÓöþ½øÖÆÁ÷(byte[])´´½¨ÊµÀý¡£µ±È»ÎÒÃÇ¿ÉÒÔ°ÑÄÚ´æÖеĶþ½øÖÆÁ÷дµ½ÎļþÖУ¬ÔÙÈÃFileDataSource¶Á½øÀ´¡£
µ«ÊÇÕâÑù»á¸ø·þÎñÆ÷´øÀ´¶øÍâµÄÓ²Å̶Áд£¬Èô²Ù×÷Ƶ·±£¬»áÔì³É·þÎñÆ÷ÐÔÄÜϽµ¡£ÐÒÔ˵ÄÊÇÎÒÔÙÍøÉÏ·¢ÏÖÁËÕâôһ¸öÀ࣬¿ÉÒÔÖ±½ÓÓöþ½øÖÆÁ÷Ö±½Ó´´½¨ÊµÀý¡£
import java.io.*;
import javax.activation.*;
public class ByteArrayDataSource implements DataSource
{
/*** Data to write. */
private byte[] _data;
/*** Content-Type. */
private String _type;
/* Create a datasource from an
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
½ñÌìÎÒѧϰÁË·´ÉäÓë¶àÏ̵߳Ä֪ʶ
·´É䣺Class cls1=Date.class//×Ö½ÚÂë1£»
Class cls2=Person.class//×Ö½ÚÂë2£»
P1.getClass();//µÃµ½×Ö½ÚÂë
Class.forName(“java.lang.String”) //µÃµ½Õâ¸öÀàµÄ×Ö½ÚÂë
ºǫ́Ïß³ÌÓëÁªºÏÏß³Ì
l & ......
javaÉÏ´«Îļþ
ÐèÒªµÄµÚÈý·½jar°üÓУ¨ÕâÀïʹÓÃapacheµÄ£©
apacheµÄcommons-fileupload£¨ÉÏ´«Óã©£¬commons-io £¨listenerÇåÀíÀàÓã© £¬ commons-beanutils£¨¿ÉÑ¡£©
¾ßÌå²Ù×÷
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
if(ServletFileUp ......
Java™ ÓïÑÔ°üº¬Á½ÖÖÄÚÔÚµÄͬ²½»úÖÆ£ºÍ¬²½¿é£¨»ò·½·¨£©ºÍ volatile ±äÁ¿¡£ÕâÁ½ÖÖ»úÖƵÄÌá³ö¶¼ÊÇΪÁËʵÏÖ´úÂëÏ̵߳ݲȫÐÔ¡£ÆäÖÐ Volatile ±äÁ¿µÄͬ²½ÐԽϲµ«ÓÐʱËü¸ü¼òµ¥²¢ÇÒ¿ªÏú¸üµÍ£©£¬¶øÇÒÆäʹÓÃÒ²¸üÈÝÒ׳ö´í¡£ÔÚÕâÆÚµÄ Java ÀíÂÛÓëʵ¼ù
ÖУ¬Brian Goetz ½«½éÉܼ¸ÖÖÕýȷʹÓà volatile ±äÁ¿µÄģʽ£¬²¢Õ ......
°Ñ֮ǰÏîÄ¿ÖÐдµÄÒ»¸öJavaͨÓÃÑéÖ¤Âë³ÌÐòÕûÀíÁËһϣ¬Óë´ó¼Ò·ÖÏí£¬Ï£ÍûÄÜÅ×שÒýÓñ¡£
Ò»¡¢Ö÷Òª¹¦ÄÜ£º
1¡¢Ö§³Ö´¿Êý×Ö¡¢´óд×Öĸ¡¢Ð¡Ð´×Öĸ£¬¼°Á½Á½»ìºÏ»òÈýÕß»ìºÏÀàÐÍÑéÖ¤Â룻
2¡¢Ö§³Ö×Ô¶¨ÒåÌØÊâ×Ö·ûÅųý£¨Èç0oOi1jI£©£»
3¡¢Ö§³ÖͼƬ¼°ÎÄ×ÖÁ½ÖÖÀàÐÍÑéÖ¤Â룻
4¡¢Ö§³Ö×Ô¶¨ÒåÑéÖ¤ÂëͼƬ´óС£»
5¡¢Ö§³Ö×Ô¶¨Òå¸ÉÈÅÏßÌõÊý£»
......