2 a877536298 a877536298 于 2015.06.19 09:19 提问

JSP怎么生成静态HTML页面

JSP怎么生成静态HTML页面,在eclipse平台里,用Java代码

3个回答

bulusli3
bulusli3   Ds   Rxr 2015.06.19 10:05

用servlet的response直接输出html页面代码即可。

xiaoyu2430
xiaoyu2430   2015.06.19 10:18

public class HTMLMaker { final static Object lock = new Object(); public static void makeHtml(String page, String filePath){ makeHtml(page,filePath,"UTF-8"); } public static void makeHtml(String page, String filePath,String chartset) { synchronized (lock) { HttpURLConnection huc = null; BufferedReader br = null; BufferedWriter bw = null; try { huc = (HttpURLConnection)new URL(page).openConnection(); System.setProperty("sun.net.client.defaultConnectTimeout", "30000"); System.setProperty("sun.net.client.defaultReadTimeout", "30000"); huc.connect(); InputStream stream = huc.getInputStream(); bw = new BufferedWriter(new OutputStreamWriter (new FileOutputStream(filePath),chartset)); br = new BufferedReader(new InputStreamReader(stream, chartset)); String line; while((line = br.readLine())!= null){ if(line.trim().length() > 0){ bw.write(line); bw.newLine(); } } }catch (Exception e) { e.printStackTrace(); }finally { try { br.close(); bw.close(); huc.disconnect(); }catch (Exception e) { e.printStackTrace(); } } } }}

beacon_2011
beacon_2011   Rxr 2015.06.19 12:27

freemaker试试

Csdn user default icon
上传中...
上传图片
插入图片