方案一:使用不同“上下文路径”(Context Path)
适用场景:两个模块都在同一个Tomcat实例中部署。
操作步骤:
将新模块的帆软工程(比如叫 module2.frm)部署到同一个Tomcat下的另一个Web应用目录。
例如:webapps/module2/
修改 server.xml 或使用独立的 context.xml 配置新应用的上下文路径(可选,默认就是文件夹名)。
访问方式:
原模块:http://:<端口>/report1
新模块:<a href="http://:<端口>/module2">http://:<端口>/module2
方案二:使用“子域名” + Nginx反向代理 — 企业级推荐
适用场景:对外提供更友好的访问方式,或需要HTTPS、负载均衡等。
操作步骤:
申请或配置两个子域名(需DNS支持):
report1.yourcompany.com
report2.yourcompany.com
server {
listen 80;
server_name report1.yourcompany.com;
location / {
proxy_pass http://localhost:8080/report1;
}
}
server {
listen 80;
server_name report2.yourcompany.com;
location / {
proxy_pass http://localhost:8080/module2; # 或 http://localhost:8081
}
}