mercredi 29 mars 2017

tomcat deploy module war to sub url path

I have a multi-module maven project whose structure looks like this:

app                // parent/root project folder
 |- src         
 |- target
      |- app.war   // common features
 |- app-payment    // child/module folder
        |- src   
        |- target
             |- app-payment.war  // shop/pay features

How can I map the two war files to urls like below?

requests for    
   localhost:8080/app/payment   --goto-->   $CATALINA_HOME/webapps/app-payment.war (or any other locations, doesn't matter)
other requests for
   localhost:8080/app           --goto-->   $CATALINA_HOME/webapps/app.war

The web.xml -> <servlet-mapping> both are <url-pattern>/</url-pattern>.

I'm using tomcat 8.5 and want to keep default settings if possible (e.g., do not add <Context> in server.xml, leave autoDeploy=true). So probably the approaches provided in A word on Contexts at http://ift.tt/2nL5N06 would not work (have tried anyway and no).

In case this turns out to be an XY problem...Is it the right way to use/modify tomcat to achieve such url pattern? Or should I change the project settings (or design)? It's a spring-mvc project and the whole spring-*.xml thing is like a myth...




Aucun commentaire:

Enregistrer un commentaire