jsp页面img利用tomcat配置访问服务器绝对路径显示图片

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 &quot;%r&quot; %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/" ..>一致

上一篇:poj_3662 最小化第k大的值


下一篇:nvl函数 oracle