2017-03-07 44 views
0

試圖調用郵件類從JSP越來越無法喲編譯錯誤:試圖從JSP調用類得到解決不了的錯誤

我的JSP的樣子:

<form action="books.jsp" method="post"> 
    <% 

    Mailer.send("[email protected]","himagiri","[email protected]","himagiri",password1); 

    //change from, password and to  
%> 

我的郵件類,如下所示

class Mailer{ 
    public static void send(final String from,final String password,String  to,String sub,String otp){ 
     //Get properties object  
     System.out.print("ghfgm"); 
     Properties props = new Properties();  
     props.put("mail.smtp.host", "smtp.gmail.com");  
     props.put("mail.smtp.socketFactory.port", "465");  

     //get Session 
     Session session = Session.getDefaultInstance(props,   
      new javax.mail.Authenticator() {  
       protected PasswordAuthentication getPasswordAuthentication() {  
        return new PasswordAuthentication(from,password); 
       }  
      } 
     );  
     //compose message     
    }  
} 

無法編譯類:

org.apache.jasper.JasperException: Unable to compile class for JSP: 

    An error occurred at line: 36 in the jsp file: /otp.jsp 
    Mailer cannot be resolved 
33:   } 
34:   String password1=new String(otp); 
+1

導入梅勒? –

+0

我可以知道如何導入? – RMR

+0

即使導入後出現相同的錯誤 – RMR

回答

0

創建Mailer類的物體,像

Mailer m = new Mailer(); 
m.send("[email protected]","himagiri","[email protected]","himagiri",password1); 

試試這個代碼,我認爲它會工作...

相關問題