用myeclipse写jsp,建的项目上有个小叹号。一个warning提示,目前未发现有影响,不知道今后有影响吗?
我是初学者,很多东西不太明白,还望见谅,谢谢。 sqljdbc4.jar 是sql server的驱动,我在myeclipse中导入了,webroot/web_inf/lib和tomcat的lib下也放了,classpath也设置了。关键是!!数据库连接成功!!就是不知道这个warning有没有问题呢???? warning提示如下: Classpath entry F:/软件/编程/Microsoft SQL Server JDBC Driver 3.0/sqljdbc_3.0/chs/sqljdbc4.jar will not be exported or published. Runtime ClassNotFoundExceptions may result. Classpath Dependency Validator Message
这个提示说明你的程序在eclipse中是可以运行的,但是你把程序打成发布包发布时,sqljdbc4.jar不会被打包进去。 出现这个warning的原因可能是你用导入外部jar包的方式导入。 导入jar包的方式有好几种,只要一种就可以了,常用的就是把jar复制到WEB-INF/lib下面, 你把jar放到tomcat的lib下是多余的(这也是一种方式,一般不会这样做),使用多种方式导入jar可能还会导致意想不到的冲突。 提问者评价 原来是这样。谢谢。你
<%@ page import="java.io.*,java.util.*,javax.mail.*"%> <%@ page import="javax.mail.internet.*,javax.activation.*"%> <%@ page import="javax.servlet.http.*,javax.servlet.*" %> <% String result; // 收件人的电子邮件 String to = "78@qq.com"; // 发件人的电子邮件 String from = "test@163.com"; // 假设你是从本地主机发送电子邮件 String host = "smtp.163.com"; // 获取系统属性对象 Properties properties = System.getProperties(); // 设置邮件服务器 properties.setProperty("mail.smtp.host", host); properties.put("mail.smtp.auth", "true"); // 获取默认的Session对象。 Session mailSession = Session.getDefaultInstance(properties,new Authenticator(){ public PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("tes@163.com", "test"); //发件人邮件用户名、密码 } }); try{ // 创建一个默认的MimeMessage对象。 MimeMessage message = new MimeMessage(mailSession); // 设置 From: 头部的header字段 message.setFrom(new InternetAddress(from)); // 设置 To: 头部的header字段 message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); // 设置 Subject: header字段 message.setSubject("This is the Subject Line!"); // 现在设置的实际消息 message.setText("This is actual message"); // 发送消息 Transport.send(message); result = "Sent message successfully...."; }catch (MessagingException mex) { mex.printStackTrace(); result = "Error: unable to send message...."; } %> <html> <head> <title>Send Email using JSP</title> </head> <body> <center> <h1>Send Email using JSP</h1> </center> <p align="center"> <% out.println("Result: " + result + "\n"); %> </p> </body> </html>