Today, I have a JSP or ASP.NET pre-compilation tool ...

xiaoxiao2021-03-06  108

The principle is very simple. Although some JSP WebServer provides pre-compiled features, you can also try it yourself. Mainly uses Java's httpurlconnection and java.io. *; the following is console code: package sam.bobpig.com Import java.io. *; import java.net. *; / ** *

Title: ASP.NET or JSP precompile program *

description: *

Copyright: Copyright (C) 2004 *

Company: Chongqing flight digital company * @Author Song Yunyi * @version 1.0 * /

Public class precomplie {public static filefilter filefilter = new precompilefilefilter (); public url rooturl

Public precomplie (url arooturl) {rooturl = arbooturl;

// public void precompiledirectory (file dir, string startdir) {file [] files = dir.listfiles (filefilter); for (int i = 0; i

Public void precompilefile (file file, string startdir) {Try {url precompileurl = new url (rooturl, startdir "/" file.getname () "ASP_PRE = true");

//System.out.println (rooturl.tostring ()); system.out.println (precompileurl.tostring ());

HttpURLConnection conn = (HttpURLConnection) precompileURL.openConnection (); int responseCode = conn.getResponseCode (); System.out.println (rootURL startDir "/" file.getName () "has ok! [" ResponseCode "] ");} Catch (Exception Exc) {system.out.println (" Exception: " EXC.TOSTRING () " for " startdir file.getname ());

}

Public static void main (string [] args) {if (Args.Length <2) {system.out.print ("please supportory ..."); system.exit (0);} Try {string starturl = args [0]; file start = new file (args [1]);

Precomplie Precomp = New Precomplie (New URL);

IF (Start.Indirectory ()) {Precomp.Precompiledirectory (Start, ");} else {precomp.precompilefile (start,");}} catch (exception eXC) {EXC.PRINTSTACKTRACE ();

}

Class Precompilefilefilter Implements Filefilter {Public Boolean Accept (F.IsDirectory ()) Return True; if (F.GetName (). Endswith (". aspx")) Return True; Return False;}}

转载请注明原文地址:https://www.9cbs.com/read-97750.html

New Post(0)