JavaMail

20 12 月, 2009

J2EE项目里有用到JavaMail,研究了下。下面是参考资料和我的JavaMail:

JavaMail

J2EE JavaMail

如何使用JSP发送邮件

java利用JavaMail实现邮件功能

package mail;

import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class Mail {
     private Properties props;//系统属性,可以get和put属性名值对。
     private Session session;//根据系统属性设置会话
     private Message msg;//MimeMessage为其子类
     //管理员SMTP服务器信息
     private String host;
     private String username;
     private String password;
     private String from;

     public Mail(String host, String username, String password, String from) {
        props = System.getProperties();
        //props.put(“mail.smtp.host”, “smtp.jspinsider.com”);
        props.put(“mail.smtp.host”, host);
        props.put(“mail.smtp.auth”, “true”);
        session = Session.getDefaultInstance(props);
        msg = new MimeMessage(session);
        this.host = host;
        this.username = username;
        this.password = password;
        this.from = from;
     }

     public void send(String to) throws MessagingException {
        msg.setFrom(new InternetAddress(from));
        msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
        msg.setSubject(“测试”);
        msg.setText(“测试”);
        Transport transport = session.getTransport(“smtp”);
        transport.connect((String)props.get(“mail.smtp.host”), username, password);
        transport.sendMessage(msg, msg.getRecipients(Message.RecipientType.TO));
        transport.close();
        //Transport.send(msg);
     }
}

MyEclipse安装与配置

20 12 月, 2009

MyEclipse7.0破解下载

MyEclipse 7.0的汉化

详解Eclipse+MyEclipse完全绿色版制作方法

JDK+MyEclipse+Tomcat的配置

MySQL外键

19 12 月, 2009

调试J2EE项目的时候悲剧地发现MySQL默认的MyISAM引擎不支持外键,仅有InnoDB引擎支持。也就意味着不能实现“on delete cascade”,得在建表的时候使用“ENGINE=InnoDB”了。

参考资料:MySQL外键的使用

Lex Version0.4 class Heap

4 12 月, 2009

Lex Version0.4到此为止已经完成了编译原理的实验,实现了从词法分析到语法分析再到语义分析生成三地址码的过程。

class Heap部分根据语义分析生成三地址码的需要进行了部分修改。全部代码稍后放出。

#ifndef _HEAP_H_
#define _HEAP_H_
class Heap {
private:
 int syn[100];//存储词法分析后的符号表种别码
 char token[100][10];//存储词法分析后的符号表词素
 int head, tail;//游标,head表示当前使用的位置,tail表示当前可用的第一个位置。
public:
 Heap();
 ~Heap();
 int first();//head=0并返回该syn。-1表示失败。
 int prev();//head前移并返回该syn。-1表示失败。
 int next();//head后移并返回该syn。-1表示失败。
 bool append(int, char*);//加入syn和token
 char* getToken();//获得当前词素
};
#endif

#include “StdAfx.h”
#include “Heap.h”
#include <string.h>

Heap::Heap()
{
 for(int i = 0; i < 100; i++)
  syn[i] = -1;
 memset(token, 0, sizeof(token));
 head = tail = 0;
}

Heap::~Heap()
{

}

int Heap::first()
{
 head = 0;
 return syn[head];
}

int Heap::prev()
{
 if(head == 0)
  return -1;
 return syn[–head];
}

int Heap::next()
{
 if(head == tail – 1)
  return -1;
 return syn[++head];
}

bool Heap::append(int tempsyn, char* temptoken)
{
 if(tail >= 100)
  return false;
 syn[tail] = tempsyn;
 strcpy(token[tail++], temptoken);
 return true;
}

char* Heap::getToken()
{
 return token[head];
}

HTML <label> <span>

1 12 月, 2009

<label> 标签为 input 元素定义标注(标记)。

label 元素不会向用户呈现任何特殊效果。不过,它为鼠标用户改进了可用性。如果您在 label 元素内点击文本,就会触发此控件。就是说,当用户选择该标签时,浏览器就会自动将焦点转到和标签相关的表单控件上。

<label> 标签的 for 属性应当与相关元素的 id 属性相同。

<form>
  <label for="male">Male</label>
  <input type=”radio” name=”sex” id=”male” />
  <br />
  <label for="female">Female</label>
  <input type=”radio” name=”sex” id=”female” />
</form>

<span> 标签被用来组合文档中的行内元素。

span 没有固定的格式表现。当对它应用样式时,它才会产生视觉上的变化。如果不对 span 应用样式,那么 span 元素中的文本与其他文本不会任何视觉上的差异。