当我使用 tomcat 7 maven 插件在 eclipse 中运行我的 Web 应用程序时,我想要将额外的上下文部署到 tomcat。在生产环境中,使用上下文配置将此上下文映射到 tomcat dir 之外的目录
<Context path="/userimages" docBase="C:/test/userimages">
</Context>
并且通过这种方式可以在
http://wwww.myhost.com/userimages/test.jpg
我如何在 webapp 的开发环境(eclipse、tomcat7 maven 插件)上实现相同的目标? 换句话说,我希望可以通过
访问该文件夹的内容http://localhost:8080/userimages
或
http://localhost:8080/myapp/userimages
最佳答案
你应该配置 tomcat7-maven-plugin 插件。
试试这个方法:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<path>your_app_context_path</path>
<uriEncoding>utf-8</uriEncoding>
</configuration>
</plugin>
那么您所有的网址都应以 http://wwww.myhost.com/ 开头your_app_context_path/...
可以在 apache tomcat maven plugin document 找到 tomcat7:run 目标的更多可选参数
关于eclipse - tomcat7 :run 上的 Tomcat 7 maven 插件附加上下文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12196353/