下午闲来没事做,就想解决一下很久以前的一个问题,那就是java.util.zip.ZipInputStream解压文件的时候,如果包里有中文名的文件,那报错,弄了一会儿,竟然解决了,不用像以前在网上查到的要重新编译jdk的。(jdk:sun jdk1.4.2)
1.重建zip包
新建一个自己的zip包,比如com.agile.zip,在这个包中把要用到的类从jdk的源码里放到这里,用eclipse可以很同快地完成这个工作。需要所类有:DeflaterOutputStream,InflaterInputStream,ZipConstants,ZipEntry,ZipInputStream,ZipOutputStream
上面这些类在放到com.aigle.zip包中后,在Eclipse中会显示出一些错误,这里要做得就是更改import以及其它一些工作,惟一的目的就是通过编译,不再出现编译错误。
2.修改ZipInputStream
1.重建zip包
新建一个自己的zip包,比如com.agile.zip,在这个包中把要用到的类从jdk的源码里放到这里,用eclipse可以很同快地完成这个工作。需要所类有:DeflaterOutputStream,InflaterInputStream,ZipConstants,ZipEntry,ZipInputStream,ZipOutputStream
上面这些类在放到com.aigle.zip包中后,在Eclipse中会显示出一些错误,这里要做得就是更改import以及其它一些工作,惟一的目的就是通过编译,不再出现编译错误。
2.修改ZipInputStream
《每一个WEB应用程序,都应该有两个过滤器》by Jayson Falkner
原文如下:
Almost every single web application you will ever make will seriously benefit from using servlet filters to both cache and compress content. A caching filter optimizes the time it takes to send back a response from your web server, and a compression filter optimizes the size of the content that you send from your web server to a user via the Internet. Since generating content and sending content over the World Wide Web are the bread and butter of web applications, it should be no surprise that simple components that aid in these processes are incredibly useful. This article details the process of building and using a caching filter and a compression filter that are suitable for use with just about any web application. After reading this article, you will understand caching and compressing, have code to do both, and be able to apply caching and compression to any of your future (or existing!) web applications.
Review: Servlet Filters in 10 Sentences
Servlet filters are powerful tools that are available to web application developers using the Servlet 2.3 specification or above. Filters are designed to be able to manipulate a request or response (or both) that is sent to a web application, yet provide this functionality in a method that won't affect servlets and JSPs being used by the web application unless that is the desired effect. A good way to think of servlet filters is as a chain of steps that a request and response must go through before reaching a servlet, JSP, or static resource such as an HTML page in a web application. Figure 1 shows the commonly used illustration of this concept.
原文如下:
Almost every single web application you will ever make will seriously benefit from using servlet filters to both cache and compress content. A caching filter optimizes the time it takes to send back a response from your web server, and a compression filter optimizes the size of the content that you send from your web server to a user via the Internet. Since generating content and sending content over the World Wide Web are the bread and butter of web applications, it should be no surprise that simple components that aid in these processes are incredibly useful. This article details the process of building and using a caching filter and a compression filter that are suitable for use with just about any web application. After reading this article, you will understand caching and compressing, have code to do both, and be able to apply caching and compression to any of your future (or existing!) web applications.
Review: Servlet Filters in 10 Sentences
Servlet filters are powerful tools that are available to web application developers using the Servlet 2.3 specification or above. Filters are designed to be able to manipulate a request or response (or both) that is sent to a web application, yet provide this functionality in a method that won't affect servlets and JSPs being used by the web application unless that is the desired effect. A good way to think of servlet filters is as a chain of steps that a request and response must go through before reaching a servlet, JSP, or static resource such as an HTML page in a web application. Figure 1 shows the commonly used illustration of this concept.