你就用System.out.print();在控制台输出一下内容咯!例如一下就是访问配置文件并输出相应变量的方法
public void capturePropertys(String driver,String url,String user,String password){
Properties prop = new Properties();
InputStream is = a_connection_Propertys.class.getResourceAsStream("db.properties");
//getClass().getResourceAsStream("mysql.properties");
try{
prop.load(is);
}catch(IOException e)
{
System.out.println("[Dbconnection]打开 文件 出错");
}
this.jdbc = prop.getProperty(driver);
this.url = prop.getProperty(url);
this.user = prop.getProperty(user);
this.password = prop.getProperty(password);
System.out.println("jdbc="+this.jdbc);
System.out.println("url="+this.url);
System.out.println("user="+this.user);
System.out.println("password="+this.password);
}
普通java类访问WEB-INF目录下的文件的方法:
1、申明文件对象
File myConfigFile = new File(getClass().getProtectionDomain().getCodeSource().getLocation().getFile());
System.out.println("Finding calss path first then remove classes from the path " + myClass.getCanonicalPath().replaceFirst("classes", "")+"reportFIle/report01/reports.xml")
2、替换classes然后加入文件路径。
File f = new File(myClass.getCanonicalPath().replaceFirst("classes", "")+"reportFile/report01/reports.xml")
3、解析web-inf下的xml文件:
document = docBuilder.parse(new File(myClass.getCanonicalPath().replaceFirst("classes", "")+"reportFile/report01/reports.xml"));
标签
<%@ taglib uri="/WEB-INF/testTag.tld" prefix="tt" %>