2015-04-23 157 views
0

我試圖映射澤西島請求檢索使用以下映射的圖像。以下作品路徑suchs作爲澤西路徑註釋不映射所有文件類型

  • /test/file.png
  • /test/file.gif
  • /test/file.jpeg

但它未能地圖

  • /test/file.jpg

我沒有其他的映射,所以它不能與另一個映射衝突。爲什麼澤西不能繪製包含.jpg的路徑?

@GET 
@Path("/{pathPrefix}/{file}") 
public Response getImage(@PathParam("pathPrefix") String pathPrefix, 
         @PathParam("file") String file 
+1

你把xml文件放到什麼地方 – Shang

+0

老天爺你發現問題了!我把jpg列爲WebPageContentRegex,甚至不知道它。我會把它作爲答案。謝謝! –

回答

0

在我的web.xml中,我找到了下面一行將「jpg」列爲WebPageContentRegex的行。從內容集中刪除那個值解決了這個問題

<init-param> 
    <param-name>com.sun.jersey.config.property.WebPageContentRegex</param-name> 
    <param-value>.*\.(html|ico|jsp|jpg|css)</param-value> 
</init-param>