这是我的servlet
import Bean.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import Bean.Customer;
public class ViewServlet extends HttpServlet
{
private Bean.Customer customer;
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException
{
String ID = "xuefeng";
customer = Bean.Customer.getRecord(ID);
PrintWriter out = response.getWriter();
out.print("<html>");
out.print("<body>");
if(customer == null)
out.print("sdfsdf");
out.print("<h2>The information of the user:<h2><br>");
out.print("</body>");
out.print("</html>");
}
}
在与它同级的Bean(自己创建)文件夹里有Customer.class
但是上述代码返回的customer 为空
可是test.java
import Bean.*;
import java.sql.*;
public class test
{
public static void main(String[] args){
try
{
String ID = "xuefeng";
Customer customer = Customer.getRecord(ID);
System.out.println(customer.getFirstname() + " ");
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
}
运行正常,是servlet需要额外配置什么东西么???
请大家赐教