例如:
String[] args = new String[3]{"a","b","c"};
类名.main(args);

解决方案 »

  1.   

    在jsp里将类实例化,然后就可以调用她的方法了。
    如果是静态类的话,可以直接调用她的方法。
    e.g.<%
       Yourclass test=new Yourclass();
       Yourclass.yourmethod();
    %>
      

  2.   

    static的意思就是静态的,他就是说可以用类名直接调用方法.
    yourClassName.main(new String[] args)
    不过这样不好.
    看你的代码.可以直接定义类后调用listMails("abc","abc","abc");
    方法
      

  3.   

    <%
       new Class();
    %>
      

  4.   

    感觉还是不要调用main函数比较好吧。可以换个别的名字
      

  5.   

    <%
       你的class名 test=new 你的class名();
       test.你的class里面的方法名();
    %>
      

  6.   

    还是不知道如何调用啊!……痛苦以下是我的java文件
    package my;import java.io.IOException;
    import java.io.InputStream;
    import java.io.UnsupportedEncodingException;import javax.mail.BodyPart;
    import javax.mail.FetchProfile;
    import javax.mail.Folder;
    import javax.mail.Message;
    import javax.mail.MessagingException;
    import javax.mail.Multipart;
    import javax.mail.Session;
    import javax.mail.Store;
    import javax.mail.UIDFolder;
    import javax.mail.URLName;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeUtility;
    import com.sun.mail.pop3.POP3Folder;
    /**
     * 邮件接收演示例子
     * @author liudong
     */
    public class MailFetcher {
     
     public static void listMails(String host,String user,String password)
       throws IOException, MessagingException {
      listMails(host,110,user,password);
     }
     
    public static void listMails(String host,int port,String user,String password)
       throws IOException, MessagingException {
      //pop3必须小写
      URLName url = new URLName("pop3", host, port, "", user, password);
      Session session = Session.getDefaultInstance(System.getProperties(),null);
      Store store = session.getStore(url);
      POP3Folder inbox = null;
      try {
       store.connect();
       inbox = (POP3Folder) store.getFolder("INBOX");
       inbox.open(Folder.READ_ONLY);
       FetchProfile profile = new FetchProfile();
       profile.add(UIDFolder.FetchProfileItem.UID);  
       profile.add(FetchProfile.Item.ENVELOPE);
       Message[] messages = inbox.getMessages();
       inbox.fetch(messages, profile);
       for (int i = 0; i < messages.length; i++) {
        //邮件发送者
        String from = decodeText(messages[i].getFrom()[0].toString());
        InternetAddress ia = new InternetAddress(from);
        System.out.println("FROM:"+ia.getPersonal());
        //邮件发送者地址
        System.out.println("FROM_ADDR:"+ia.getAddress()); 
        //邮件标题
        System.out.println("TITLE:"+messages[i].getSubject());
        //邮件的唯一标识信息
        System.out.println("UID:"+inbox.getUID(messages[i]));
        //邮件大小
        System.out.println("SIZE:"+messages[i].getSize());
        //邮件发送时间
        System.out.println("DATE:"+messages[i].getSentDate()); 
        //读取邮件内容
        Object content = messages[i].getContent();
        if(content instanceof String)
         System.out.println("CONTENT:"+content);    
        else
        if(content instanceof Multipart)    
         dumpMultipart((Multipart)content);
       }
      } finally {
       try{
        inbox.close(false);
       }catch(Exception e){}
       try{
        store.close();
       }catch(Exception e){}
      }
     }
     
     protected static String decodeText(String text) throws UnsupportedEncodingException{
      if(text==null)
       return null;
      if (text.startsWith("=?GB") || text.startsWith("=?gb"))
       text = MimeUtility.decodeText(text);
      else 
       text = new String(text.getBytes("ISO8859_1"));  
      return text;  
     }
     
     protected static void dumpMultipart(Multipart mmp) throws MessagingException, IOException{
      for(int pc=0;pc<mmp.getCount();pc++){
       BodyPart bp = mmp.getBodyPart(pc);
       Object content = bp.getContent();
       if(content instanceof String){
        System.out.println("CONTENT:"+content);
       }
       else
       if(content instanceof Multipart)
        dumpMultipart((Multipart)content);
       else
       if(content instanceof InputStream)
        System.out.println("FileName:"+decodeText(bp.getFileName()));   
      }
     }
     
     public static void main(String[] args) throws IOException, MessagingException {
      listMails("pop3.163.com","用户名","密码");
     }
    }
    我的jsp文件,该如何调用呢?
    <%@ page contentType="text/html; charset=ISO8859_1" %>
    <%@ page import="my.MailFetcher"%>
    <%
           MailFetcher test = new MailFetcher();
           test.main();
    %> 
    我的jsp文件,该如何调用呢?
    请高手帮忙
      

  7.   

    <%@page language="java" import="java.sql.*"%>
    <%@page contentType="text/html;charset=gb2312"%>
    <html>
        <head>
        <title></title>
        </head>
        <body>
        <jsp:useBean id="action" scope="page" class="oracle.DBAction"/>
    <%
        String userid = request.getParameter("userid");//获得传入的参数
        if(!"".equals(userid==null?"":userid)){
            action.performDel(userid);  //类定义的方法,这里执行删除操作
        }
    %>
        </body>
    </html>其中class="oracle.DBAction"用来指定你的类,id="action"用来给类创建对象。
      

  8.   

    我想使用MailFetcher这个类,但不知道JSP如何调用烦烦烦烦烦烦烦
      

  9.   

    main()方法是一个类的入口,最好不要调用它!
      

  10.   

    该如何使用MailFetcher这个类呢