I am using Maven with Jetty / Tomcat. My pom.xml declares the ID of my application as <artifactId>webapp</artifactId>. Consequently, all my webapp source is located in src/main/java/webapp. Now, whenever I run any of the webserver, my URL looks like this:
http://localhost:8080/webapp/index.html
and I haven't found a clue that tells me how to get ri开发者_如何学Pythond of the application or dir name and make the URL look like this:
http://localhost:8080/index.html
Any hints?
Couple of ways you could do this:
- In Tomcat, rename the 
webapp.wartoROOT.war(note the capitalization) - Configure Apache on top of that and create a rewrite rule for pointing root to correct webapp.
 - Use Jetty's contextPath
 
Assuming you mean using the jetty:run and tomcat:run mojos (if not, please specify what you mean):
In Jetty, use the contextPath argument:
<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>maven-jetty-plugin</artifactId>
    <!-- version omitted -->
    <configuration>
        <contextPath>/</contextPath>
        <!-- other config -->
    </configuration>
</plugin>
In Tomcat it's the path argument
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>tomcat-maven-plugin</artifactId>
    <!-- Version omitted -->
    <configuration>
        <path>/</path>
        <!-- Other configuration -->
    </configuration>
</plugin>
                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                        
 加载中,请稍侯......
      
精彩评论