[b]利于tomcat实现apache的虚拟目录访问。适用于有特殊需求的情况。[/b]
tomcat 配置:
1. context 配置
1)在/conf/server.xml的host中增加:
2)独立context.xml
目录:\conf\Catalina\localhost\download.xml
[color=red]注意:.xml文件名与path要相同。[/color]
2. 在/conf/web.cml中修改:
修改:[color=red]listings的value为true[/color]
[img]http://dl2.iteye.com/upload/attachment/0097/6213/0801db2c-4d19-3559-bc13-08b1691fa402.png[/img]
3. 中文文件名
[color=red]注意:如果有文件是中文则需要配置 URIEncoding="utf-8" 否则中文文件名的文件不能被打开。[/color]
[img]http://dl2.iteye.com/upload/attachment/0099/1247/6c702130-fcd3-3b4d-936a-f2031bf08681.jpg[/img]
tomcat 配置:
1. context 配置
1)在/conf/server.xml的host中增加:
<Context docBase="D:/downloadImage" path="/download" />
2)独立context.xml
目录:\conf\Catalina\localhost\download.xml
<?xml version='1.0' encoding='utf-8'?>
<Context docBase="D:/downloadImage" path="/download" ></Context>
[color=red]注意:.xml文件名与path要相同。[/color]
2. 在/conf/web.cml中修改:
修改:[color=red]listings的value为true[/color]
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<!-- 设置可以访问虚拟目录 default false -->
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
[img]http://dl2.iteye.com/upload/attachment/0097/6213/0801db2c-4d19-3559-bc13-08b1691fa402.png[/img]
3. 中文文件名
<Connector port="8080" protocol="HTTP/1.1" URIEncoding="utf-8"
connectionTimeout="20000"
redirectPort="8443" />
[color=red]注意:如果有文件是中文则需要配置 URIEncoding="utf-8" 否则中文文件名的文件不能被打开。[/color]
[img]http://dl2.iteye.com/upload/attachment/0099/1247/6c702130-fcd3-3b4d-936a-f2031bf08681.jpg[/img]