Service Container Static Resource Configuration

The server static file configuration, such as the uploaded local image to the disk, is mapped through static access.

http://192.168.0.101/static/2015/12/10/0000.jpg

 

1. Configure the apache-tomcat-8.0.24\conf\Catalina\localhost directory in Tomcat to add the static.xml file, the content is as follows

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/static"  
	docBase="D:\img"
	privileged="true"
	reloadable="false"
	debug="0"  
	workDir=""   />

 The name of the static resource service is the name of the xml file.

 

2. Configure jetty9.2.9\etc in Jetty Modify the jetty.xml file, mainly configure the interception item of Handler

<Set name="handler">
      <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
        <Set name="handlers">
         <Array type="org.eclipse.jetty.server.Handler">
         	<Item>
               <New id="resoure" class="org.eclipse.jetty.server.handler.ContextHandler" >
                    <Set name="contextPath">/static</Set>
                        <Set name="handler">
                             <New class="org.eclipse.jetty.server.handler.ResourceHandler" >
                                   <Set name="resourceBase">D:\img </Set>
                             </New>
                        </Set>
                </New>
           </Item>
           <Item>
             <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
           </Item>
           <Item>
             <New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
           </Item>
           <Item>
             <New id="AccessLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
           </Item>
         </Array>
        </Set>
      </New>
    </Set>

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326903414&siteId=291194637