關於Resin虛擬目錄配置的問題

項目中多個項目需要同時引用一個靜態資源,所以就想到配置不同的虛擬目錄指到同一個目錄。於是有下面的配置:
    <!-- configures the default host, matching any host name -->
    
<host id="" root-directory=".">
      
<!--
         - configures an explicit root web-app matching the
         - webapp's ROOT
        
-->
      
<web-app id="/" document-directory="webapps/ROOT"/>
      
<web-app id="/community/jsvm2" document-directory="D:\\projects\\FelooComponents\\jsvm2"/>
      
<web-app id="/passport/jsvm2" document-directory="D:\\projects\\FelooComponents\\jsvm2"/>
    
</host>

       但是發現這樣只有後面一個管用(http://localhost:8080/passport/jsvm2)這個是可以,可是(http://localhost:8080/community/jsvm2)就不行,很是鬱悶。只要後面的document-directory不是同一個目錄就成。
       後來在resin的doc裏面看到path的配置

path-mapping

child of: web-app-default, web-app

Maps url patterns to real paths. If using a server like IIS, you may need to match the server's path aliases.

AttributeMeaningdefault
url-patternA pattern matching the url: /foo/*, /foo, or *.foo
url-regexpA regular expression matching the url
real-pathThe prefix of the real path. When used with url-regexp, allows substitution variables like $1.

<web-app id='/'>
            <path-mapping url-pattern='/resin/*'
            real-path='e:\resin'/>
            <path-mapping url-regexp='/~([^/]*)'
            real-path='e:\home$1'/>
            </web-app>
            

改正這樣的配置就ok了。

        <web-app id="/community" document-directory="D:\\projects\\FelooCommunityWeb">
          
<path-mapping url-pattern='jsvm2/*'
              
real-path='D:\\projects\\FelooComponents\\jsvm2'/>
      
</web-app>
      
            
<web-app id="/passport" document-directory="D:\\projects\\FelooPassportWeb">
          
<path-mapping url-pattern='jsvm2/*'
              
real-path='D:\\projects\\FelooComponents\\jsvm2'/>
      
</web-app>
創造共用協議:署名,非商業,保持一致   除經特別註明外,本文章版權歸莫多泡泡所有.
署名,非商業用途,保持一致.   somebody(莫多)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章