?? urlconvertor.java
字號:
/*
* Created on 2005-6-21
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.ug.sztz.domain.assistant;
import javax.servlet.ServletConfig;
import org.ug.sztz.domain.exception.IllegalServletConfigException;
/**
* @author xix
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class UrlConvertor {
ServletConfig cfg;
/**
*
*/
public UrlConvertor(ServletConfig cfg) {
this.cfg = cfg;
// TODO Auto-generated constructor stub
}
/**
* @param url relative dir such as "/images"
* @return absolute dir such as "c:/webroot/images"
*/
public String getAbsoluteDir(String url) throws IllegalServletConfigException{
return cfg.getServletContext().getRealPath(url);
}
public String getAbsoluteFile(String url, String filename) throws IllegalServletConfigException{
String dir = "";
dir = this.getAbsoluteDir(url);
//Add system separator
if("\\".equals(System.getProperty("file.separator")))
dir += "\\";
else
dir += System.getProperty("file.separator");
dir += filename;
return dir;
}
/**
* @param path such as "/images/a.gif"
* @return real path such as "c:/webroot/images/a.gif"
* @throws IllegalServletConfigException
*/
public String getAbsoluteFile(String path) throws IllegalServletConfigException{
return cfg.getServletContext().getRealPath(path);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -