在后台和前端交互时,遇到了后台存储的图片,前端根据地址无法访问,使用Tomcat搭建图片服务器

1.找到tomcat下的server.xml文件

2.配置文件下加入service节点(在原有的service节点下,新加一个service服务)

 

<Service name="newtest">
<!--分配8089端口-->
<Connector port="8089" protocol="HTTP/1.1" connectionTimeout="20000" URIEncoding="GBK" redirectPort="8443" />
<Engine name="newtest" defaultHost="localhost">
<!--name 为项目访问地址 此配置的访问为http://localhost:8089 appBase配置Tomcat下webapps下的路径-->
<Host name="localhost" appBase="D:\tomcat-9.0\apache-tomcat-9.0.5\webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false" >
<!--资源地址: D:\Program Files (x86)\Tomcat\webapps-->
<Context path="" docBase="D:\tomcat-9.0\apache-tomcat-9.0.5\webapps" debug="0" reloadable="false" />
</Host>
</Engine>
</Service>

此时输入访问路径http://localhost:8089/upload/template/littleImage/20170107065456class6.png

 

posted on 2018-04-26 16:39  撿忔  阅读(530)  评论(0编辑  收藏  举报