1、打开tomcat下的server.xml文件,路径\apache-tomcat-7.0.62\conf文件夹下。
2、下<host></host>加入<Context path="/ompa/uploads/" docBase="G:\ompa\uploads\" reloadable="true"></Context> 配置path="imgPath"是Jsp中img标签的src属性用到访问路径,docBase="G:\ompa\uploads\"是本地路径
代码如下:
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context path="/ompa/uploads/" docBase="G:\ompa\uploads\" reloadable="true"></Context>
</Host>
3、启动tomcat部署项目,jsp处代码如下:
<img src="/ompa/uploads/aa.png" /> <!--/ompa/uploads/ 与上面的<Context path="/ompa/uploads/" ..>一致