java,php,asp.net,linux,javascript,mysql,mssql,oracle,编程

调用上面类在jsp页面使用的标签

转载请注明:http://www.pmjava.com/Article/ShowInfo.asp?ID=56590
import java.util.Properties;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import com.fund858.util.DealingCharacter;
import com.fund858.util.ReadProperties;

/**
* SetupProperty.java
* Description: 从资源文件中获取属性值
*
@author li.b
*
@version 2.0
* Jun 26, 2008
*/
public class SetupProperty extends TagSupport {

   
/**
     * key : 指定将要获取资源的key; path:资源文件路径;
     * filter:是否过滤标签 encod:资源文件的编码
    
*/
   
private String key;
   
private String path;
   
private boolean filter = false;
   
private String encod = "";
   
public int doEndTag() throws JspException {
       
try {
            pageContext.getOut().write(getKey(path, key));
        }
catch (Exception e) {
            e.printStackTrace();
        }
       
return super.doEndTag();
    }
   
   
/**
     * Description:标签处理
     *
@param path
     *
@param key
     *
@return
     *
@throws Exception
    
*/
   
private String getKey(String path,String key) throws Exception{
        String result
= "";
        Properties prop
= null;
       
if(path != null && !path.equals("")){
            prop
= ReadProperties.getProperties(path);
        }
else{
            String tmp
= pageContext.getServletContext()
                .getRealPath(
"WEB-INF/application.properties");
            prop
= ReadProperties.getProperties(tmp);
        }
       
if(prop != null){
            result
= ReadProperties.getValue(prop, key,encod);
        }
       
if(result != null && !result.equals("") && filter){
           
//显示输出特殊符号
            result = DealingCharacter.filter(result);
        }
       
return result;
    }
   
   
public String getKey() {
       
return key;
    }
   
public void setKey(String key) {
       
this.key = key;
    }
   
public String getPath() {
       
return path;
    }
   
public void setPath(String path) {
       
this.path = path;
    }
   
public boolean isFilter() {
       
return filter;
    }
   
public void setFilter(boolean filter) {
       
this.filter = filter;
    }
   
public String getEncod() {
       
return encod;
    }
   
public void setEncod(String encod) {
       
this.encod = encod;
    }
   
   
}

posted on 2009-06-10 21:29 rrong_m 阅读(185) 评论(0)  编辑  收藏

<2024年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

导航

统计

常用链接

随笔档案

文章分类

文章档案

java编程

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜