html 코드를 파일에 쓰고 .html 형식으로 파일을 생성합니다.
<%
filename = test.htm
요청 (body) <>라면
set fso = server.createobject (scripting.filesystemobject)
set htmlwrite = fso.createtextfile (server.mappath (filename))
htmlwrite.write <html> <head> <title> request.form (title) </title> </head>
htmlwrite.write <body> 출력 제목 컨텐츠 : request.form (title) <br/> 출력 본문 내용 : request.form (body) </body> </html>
htmlwrite.close
fout = 아무것도 설정하지 않습니다
FSO = 아무것도 설정하지 않습니다
끝 If
%>
<양식 이름 = 양식 메소드 = 사후 액션 =>
<입력 이름 = 제목 값 = 제목 크기 = 26>
<br>
<Textarea name = body> body </textarea>
<br>
<br>
<입력 유형 = 제출 이름 = 제출 값 = html 생성>
</form>
2. 그러나 위의 방법에 따라 HTML 파일을 생성하는 것은 매우 불편하다. 템플릿 함수를 완료하려면 모든 템플릿 코드가 HTML 파일을 생성합니다.
template.htm '// 템플릿 파일
<html>
<헤드>
<title> $ title $ by jzxue.com </title>
</head>
<body>
$ body $
</body>
</html> testmplate.asp '// html을 생성합니다
<%
dim fso, htmlwrite
희미한 스트 티탈, 스트르 스텐트, 스트라우트
'// 파일 시스템 객체를 만듭니다
set fso = server.createobject (scripting.filesystemobject)
'// 웹 템플릿 파일을 열고 템플릿 내용을 읽으십시오.
set htmlwrite = fso.opentextfile (server.mappath (template.htm))
Strout = F. Readall
htmlwrite.close
Strtital = 생성 된 웹 페이지 제목
strcontent = 생성 된 웹 페이지 컨텐츠
'// 실제 콘텐츠를 사용하여 템플릿의 마크를 대체합니다.
Strout = Replace (Strout, $ title $, strtitle)
Strout = replace (Strout, $ body $, strcontent)
'// 생성 할 정적 페이지를 만듭니다
set htmlwrite = fso.createtextfile (server.mappath (test.htm), true)
'// 웹 컨텐츠에 쓰기
htmlwrite.writeline Strout
htmlwrite.close
Response.Write 정적 페이지 성공을 생성합니다!
'// 파일 시스템 객체를 해제합니다
htmlwrite = nothing을 설정하십시오
FSO = 아무것도 설정하지 않습니다
%>