创建文件WEB-INF/test.properties:
#this is test myip
myip=192.168.7.8import javax.servlet.*;
...public class my class{
 private static final String PROPFILE="/WEB-INF/test.properties"; 
 PageContext pageContext;
 Properties propfile;
 ...
 public String readprop(){
  String ls_propfile;
  propfile = new Properties();
  propfile.load(pageContext.getResourceAsStream(PROPFILE));  propfile = propfile.getProperty("myip");
  return propfile;//属性返回值
 }
}

解决方案 »

  1.   

    ResourceBundle rb = ResourceBundle.getBundle(PROPFILE);
      

  2.   

    好像要在环境变量里class_patj新增一个指向这个属性文件的变量
      

  3.   

    to yyhyan(加强对数据结构的学习) 
    你说的方法中java bean去调用PageContext,这个是javax.servlet.jsp.PageContext这个里的,一个java bean能调用jsp中的默认对象嘛?
      

  4.   

    maybe you can put this file into package, and then find this property file through package name and file name.
    e.g.
    file application.properties exists in package 'resources'then ResourceBundle bundle = PropertyResourceBundle.getBundle("resources.application");
      

  5.   

    如果你希望用http的方式获取那你就不要想了,那个在Http下是不可见的,如果其它使用绝对路径吧!!和读起它的没有区别
      

  6.   

    我觉得这样做,不知道行不行!没试过!
    你在bean中写个方法,读取、处理文件的方法,可以传入文件名及路径!
    在别的JSP中调用,那个JSP文件可以和WEB-inf文件夹之间发生联系吧,比如JSP文件和web-inf同级!
    可以通过request.getRealPath()得到真实的地址,再传给bean
    可以吗,如行,给我发短消息!