简体   繁体   中英

Jersey Path annotation not mapping all file types

I am attempting to map jersey requests to retrieve an image using the following mapping. The following works for paths suchs as

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

But it fails to map for

  • /test/file.jpg

I have no other mappings than this one so it cannot be conflicting with another mapping. Why would Jersey be unable to map a path inluding a .jpg?

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

In my web.xml I found the following line that had "jpg" listed as WebPageContentRegex. removing that value from the set of content solved the problem

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM