静态页奇怪问题
我使用Java+Spring+Velocity模板生成静态页
使用Spring做个定时器,每天零晨4点生成静态页,这个程序是在43的机器上跑的(43是一台linux),生成之后程序自动上传到正是服务器(正是服务器Freebsd),访问服务器生成静态页含有中文全是??,随后我将定时器调成10点,14点,17点并每一分钟生成一次并上传到正是服务器(当然全是在43机器上,只需要修改一下spring配置文件即可,并从启tomcat),访问时竟然没有??(正是服务器),一切显示正常!而且43机上生成文件是正常的没有??,请朋友们帮助,谢谢你们!!!下面我将代码贴出来:
Java代码
//生成静态页
try {
VelocityEngine ve = new VelocityEngine();
Properties properties = new Properties();
properties.setPropert(Velocity.FILE_RESOURCE_LOADER_PATH,PATH);
ve.init(properties);
Template t = ve.getTemplate( "statpage5.vm","GBK" );
VelocityContext context = new VelocityContext();
StringWriter strWriter = new StringWriter();
FtpUpload ftp = new FtpUpload();
context.put("list10", list10);这list10结果是数据库里数据
context.put("list20", list20);
context.put("list30", list30);
t.merge(context, strWriter);
String html_name = PATH+"ph.htm";
Writer out = new OutputStreamWriter(new FileOutputStream(html_name),"GBK");
out.write(strWriter.toString());
out.close();
ftp.uploadHtmCssFile(html_name);
}catch(Exception e){
e.printStackTrace();
}
//生成静态页
try {
VelocityEngine ve = new VelocityEngine();
Properties properties = new Properties();
properties.setPropert(Velocity.FILE_RESOURCE_LOADER_PATH,PATH);
ve.init(properties);
Template t = ve.getTemplate( "statpage5.vm","GBK" );
VelocityContext context = new VelocityContext();
StringWriter strWriter = new StringWriter();
FtpUpload ftp = new FtpUpload();
context.put("list10", list10);这list10结果是数据库里数据
context.put("list20", list20);
context.put("list30", list30);
t.merge(context, strWriter);
String html_name = PATH+"ph.htm";
Writer out = new OutputStreamWriter(new FileOutputStream(html_name),"GBK");
out.write(strWriter.toString());
out.close();
ftp.uploadHtmCssFile(html_name);
}catch(Exception e){
e.printStackTrace();
}
Java代码
//这是FTP上传,用的是这个类com.jscape.inet.ftp.Ftp;
Ftp ftp = null;
ftp = new Ftp(host,user,password,Integer.parseInt(port));
ftp.setTimeout(60000);
ftp.connect();
ftp.setAuto(false);
ftp.setBinary();使用二进制
File file = new File(localFileName);
String fileName = file.getName();
ftp.setLocalDir(file.getParentFile());
//这是FTP上传,用的是这个类com.jscape.inet.ftp.Ftp;
Ftp ftp = null;
ftp = new Ftp(host,user,password,Integer.parseInt(port));
ftp.setTimeout(60000);
ftp.connect();
ftp.setAuto(false);
ftp.setBinary();使用二进制
File file = new File(localFileName);
String fileName = file.getName();
ftp.setLocalDir(file.getParentFile());
Java代码
//模板文件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<!-- base -->
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
.....
|