做邮件系统遇到可一点问题
在处理发送邮件的jsp文件中已经引入了
<%@ page import= "javax.activation.* "%>
<%@ page import= "java.util.*,javax.mail.* "%>
<%@ page import= "javax.mail.internet.* "%>
这些是javamail和jaf的类文件包,而且已经把javamail和jaf的mail.jar和activation.jar加到了classpath里为什么编译文件时还会报错:
不认识,无法解析Session ,MimeMessage,InternetAddress等等这些类呢????
错误提示是:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 12 in the jsp file: /sendmail.jsp
Generated servlet error:
Properties cannot be resolved to a type
An error occurred at line: 12 in the jsp file: /sendmail.jsp
Generated servlet error:
Properties cannot be resolved to a type
An error occurred at line: 12 in the jsp file: /sendmail.jsp
Generated servlet error:
Session cannot be resolved to a type
An error occurred at line: 12 in the jsp file: /sendmail.jsp
Generated servlet error:
Session cannot be resolved
An error occurred at line: 12 in the jsp file: /sendmail.jsp
Generated servlet error:
MimeMessage cannot be resolved to a type
An error occurred at line: 12 in the jsp file: /sendmail.jsp
Generated servlet error:
MimeMessage cannot be resolved to a type
An error occurred at line: 12 in the jsp file: /sendmail.jsp
Generated servlet error:
InternetAddress cannot be resolved to a type
An error occurred at line: 12 in the jsp file: /sendmail.jsp
Generated servlet error:
InternetAddress cannot be resolved to a type
An error occurred at line: 12 in the jsp file: /sendmail.jsp
Generated servlet error:
InternetAddress cannot be resolved to a type
An error occurred at line: 12 in the jsp file: /sendmail.jsp
Generated servlet error:
InternetAddress cannot be resolved to a type
An error occurred at line: 12 in the jsp file: /sendmail.jsp
Generated servlet error:
Message.RecipientType.TO cannot be resolved to a type
An error occurred at line: 12 in the jsp file: /sendmail.jsp
Generated servlet error:
Date cannot be resolved to a type
An error occurred at line: 12 in the jsp file: /sendmail.jsp
Generated servlet error:
Transport cannot be resolved to a type
An error occurred at line: 52 in the jsp file: /sendmail.jsp
Generated servlet error:
MessagingException cannot be resolved to a type
An error occurred at line: 52 in the jsp file: /sendmail.jsp
Generated servlet error:
e cannot be resolved
下面是我文件里的部分代码:
Properties props=new Properties();
System.getProperties();
props.put( "mail.smtp.host ", "smtp.tom.com ");
props.put( "mail.smtp.auth ", "true ");
Session s=Session.getInstance(props,null);
s.setDebug(true);
MimeMessage message=new MimeMessage(s);
InternetAddress from=new InternetAddress( "123@tom.com ");
message.setFrom(from);
[解决办法]
try:
1. 把jar放到WEB-INF/lib中
2. <%@ page import= "java.util.*,javax.mail.* "%> 分成两行来import
p.s.
3. System.getProperties(); 这一行是多余的
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.myexception.cn/j2ee/2308.html