只在jdk1.5以下才需要:
String filepath = "";
//如果是nuix
filepath = servlet.getServletContext().getRealPath(java.io.File.separatorChar+"template"+java.io.File.separatorChar+ path);
//如果是WINDOWS
if (java.io.File.separatorChar == '\\') {
filepath = servlet.getServletContext().getRealPath("/template/" + path);
}