求助 如题  
package cn.study.dm;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class mailcheck
{


public mailcheck(){}
private static void matchingtext(String expression,String text)
{
Pattern p=Pattern.compile(expression);
Matcher m=p.matcher(text);
boolean b=m.matches();
System.out.println(b);
}}
bean文件如上

解决方案 »

  1.   

    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head>
    <jsp:useBean id="check" class="cn.study.dm.mailcheck" scope="page"/>
    <body><%String text = new String();
    text=request.getParameter("textfield4");
      String expression = new String ();
        expression ="^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$";
      
      check.matchingtext(expression,text);
     
      
      
      
    %>
    </body>
    </html>
    jsp页面文件如上
      

  2.   

    org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 16 in the jsp file: /test/1.jsp
    The method matchingtext(String, String) from the type mailcheck is not visible
    13:   String expression = new String ();
    14:     expression ="^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$";
    15:   
    16:   check.matchingtext(expression,text);
    17:  
    18:   
    19:   
    Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.报错 如上 
      

  3.   

    老大,你的matchingtext()方法还private ,并且静态,怎么调用啊,改为public