Hosting Static Content and JAX-RS Services Under the Same Root Context

后端 未结 2 975
情歌与酒
情歌与酒 2021-01-05 20:54

We have multiple Java web apps packaged as WARs all packaged in an EAR. Our RESTful services are built using JAX-RS and in version specific WARs.

We\'d like to add

2条回答
  •  醉酒成梦
    2021-01-05 21:19

    So I found a solution (tested) that works. As stated in the Resteasy Documentation - RESTEasy as a servlet Filter:

    The downside of running Resteasy as a Servlet is that you cannot have static resources like .html and .jpeg files in the same path as your JAX-RS services. Resteasy allows you to run as a Filter instead. If a JAX-RS resource is not found under the URL requested, Resteasy will delegate back to the base servlet container to resolve URLs.

    web.xml example

    
        
            Resteasy
            
                org.jboss.resteasy.plugins.server.servlet.FilterDispatcher
            
            
                javax.ws.rs.Application
                com.restfully.shop.services.ShoppingApplication
            
        
    
        
            Resteasy
            /*
        
    
    

提交回复
热议问题