Red de conocimientos turísticos - Información de alquiler - Asesoramiento técnico en la generación de archivos HTML

Asesoramiento técnico en la generación de archivos HTML

Generar archivos html estáticos puede reducir la presión del servidor. El siguiente es un ejemplo sencillo

1.buildhtml.jsp

lt;@page contentType="text/html; charset=gb2312" import="java.util.*,java .io.*"gt;

lt;

String title="Este es el título";

Prueba{

String title ="Este es el título";

String title="Este es el título".lt;

prueba{

String title="Esto es el título";

String content="Este es el área de contenido"

String editor="LaoMao"

String filePath = ""; > filePath = request.getRealPath("/") "test/template.htm";

//out.print(filePath "lt;brgt;");

String templateContent ="";

FileInputStream fileinputstream = new FileInputStream(filePath); //leer el archivo del módulo

int length = fileinputstream.available(); bytes[] = nuevo byte[longitud];

fileinputstream.replaceAll("###content###",content);

templateContent=templateContent .replaceAll("## #author####",editer); //Reemplazar la posición correspondiente en el módulo

//out.print(templateContent);

//Obtener el nombre del archivo basado a tiempo

Calendario = Calendar.getInstance();

Nombre de archivo de cadena = String.valueOf(calendar.getTimeInMillis()) ".html"; = request. getRealPath( "/") fileame; //Ruta de guardado del archivo html generado

FileOutputStream fileoutputstream = new FileOutputStream(fileame); //crear flujo de salida del archivo

byte tag_bytes[ ] = contenido de plantilla .getBytes();