ftraian
ftraian

Reputation: 658

Configuring context path for jetty with static resources

I have a maven application configured to start Jetty and also load statics from ../client . Configuration is below:

<plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>8.1.4.v20120524</version>
            <configuration>
                <scanIntervalSeconds>25</scanIntervalSeconds>
                <connectors>
                    <connector implementation="org.eclipse.jetty.server.bio.SocketConnector">
                        <port>9095</port>
                        <maxIdleTime>60000</maxIdleTime>
                    </connector>
                </connectors>
                <webAppSourceDirectory>../client/</webAppSourceDirectory>
                <webAppConfig>
                    <resourceBases>
                        <resourceBase>src/main/webapp</resourceBase>
                        <resourceBase>../client/</resourceBase>
                    </resourceBases>
                </webAppConfig>
            </configuration>
</plugin>

What I am trying to do is to move only webapp under /API resource base. To be more explicit I want to have the mappings:

src/main/webapp      --->     /API
../client/           --->     /

Upvotes: 4

Views: 3323

Answers (1)

ftraian
ftraian

Reputation: 658

Finally found the right config:

<webAppConfig>
    <contextPath>/API</contextPath>
</webAppConfig>
<contextHandlers>
    <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
        <contextPath>/</contextPath>
        <resourceBase>../client/</resourceBase>
    </contextHandler>
</contextHandlers>

Upvotes: 5

Related Questions