我在jsp调用自己的类:<%@ page import = "mas.db.LoadPropertiesTest" %>      LoadPropertiesTest imp = new LoadPropertiesTest();
     imp.load("C:\\tomcat55\\user.properties");
     
     String url = imp.getProperty("url");
     String user = imp.getProperty("user");
     String password = imp.getProperty("password");
显示的时候提示: org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 36 in the jsp file: /jsp/tmp_query.jsp
Generated servlet error:
The constructor LoadPropertiesTest() is not visible我想知道 ,哪里出了问题,谢谢!我的类代码如下;
package mas.db;import java.io.FileInputStream;
import java.io.PrintStream;
import java.util.Properties;public class LoadPropertiesTest
{
  private Properties prop = null;  LoadPropertiesTest()
  {
    prop = new Properties();
  }  public void load(String path) {
    FileInputStream stream = null;
    try
    {
      stream = new FileInputStream(path);
     prop.load(stream);      stream.close();
      stream = null;
    } catch (Exception e) {
      e.printStackTrace();
    }
  }  public String getProperty(String key) {
    return prop.getProperty(key);
  }

解决方案 »

  1.   

     LoadPropertiesTest()
      {
        prop = new Properties();
      }没加VOID吧
      

  2.   

    public LoadPropertiesTest(){
     prop = new Properties();
    }
    构造方法
      

  3.   

    public class LoadPropertiesTest
    {
      private Properties prop = null; public  LoadPropertiesTest()
      {
        prop = new Properties();
      }因为构造函数不是public,无法被别的代码访问。
      

  4.   

    构造函数必须为public类型,方可让外部构造。
      

  5.   

    public是必须的
    对你这个程序
      

  6.   

    LoadPropertiesTest 中,构造函数的访问权限被定义为default,
    也就是该类只是对同一包里面的其他类是可见的,而当在jsp中调用它
    的构造函数,由于权限问题,故在服务器解释时出错。只要你把
    LoadPropertiesTest 的构造函数定义成 public权限就可以。ps:我也建了一个项目,然后测试过的