You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修改Tomcat默认URL?实现带/dev前缀的项目访问路径

How to Add /dev Prefix to Your Dynamic Web Project URL in Tomcat

Got it, let's sort out this URL path change for your Eclipse Dynamic Web Project. You want to shift from the default http://localhost:8080/magicmonitor/... to http://localhost:8080/dev/magicmonitor/panels.jsp—here are two reliable, straightforward methods to make this happen:

Method 1: Configure Tomcat Context XML (Global Tomcat Setup)

This approach modifies Tomcat's core configuration, so the path change will apply every time you run the server:

  • Navigate to your Tomcat installation directory, then go to conf/Catalina/localhost
  • Create a new XML file named dev#magicmonitor.xml (the # character tells Tomcat to map this to a nested path)
  • Paste the following content into the file, replacing the docBase value with the absolute path to your project's web content folder (e.g., C:\eclipse-workspace\magicmonitor\WebContent on Windows, or /home/yourname/workspace/magicmonitor/WebContent on Linux/Mac):
<Context docBase="/absolute/path/to/your/magicmonitor/webapp" path="/dev/magicmonitor" reloadable="true"/>
  • Save the file and restart your Tomcat server.

Method 2: Adjust Deployment Path in Eclipse

If you prefer to configure this directly within Eclipse (so the setting is tied to your workspace), follow these steps:

  • Open the Servers view in Eclipse (if you don't see it, go to Window > Show View > Servers)
  • Right-click your Tomcat server instance and select Open to load its configuration
  • Switch to the Modules tab, then select your magicmonitor project from the list
  • Click the Edit button, then update the Path field to /dev/magicmonitor
  • Click Finish, then restart your Tomcat server to apply the change.

Quick Check After Setup

Once you've applied either method, restart Tomcat and test the new URL: http://localhost:8080/dev/magicmonitor/panels.jsp. If you get a 404 error, double-check:

  • The docBase (in Method 1) points to the correct web content folder of your project
  • The Path value (in Method 2) is exactly /dev/magicmonitor
  • Your project is properly deployed to the Tomcat server (check the webapps folder in your Tomcat directory—you should see a dev#magicmonitor folder or the deployed project files)

内容的提问来源于stack exchange,提问作者Sandip Bhot

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 08:43:23