5ol.cc 发表于 2017-1-28 10:43:26

Tomcat类装载器

context.xml:
<Context>
<Resource name="mail/session"
auth="Container"
type="javax.mail.Session"
mail.smtp.host="smtp.sina.com.cn"
mail.transport.protocol="smtp"
mail.smtp.auth="true"/>
</Context>



MailServlet.java:
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
Session session = (Session) envCtx.lookup("mail/Session");
页: [1]
查看完整版本: Tomcat类装载器