Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
189 views
in Technique[技术] by (71.8m points)

java - Changing Tomcat context path of web project in Eclipse

I'm using Tomcat 6 and using the Servers functionality in Eclipse to manage it. I have a project named foobar and I'd like to change the context path so that the URLs referenced are http://localhost:8080/app instead of http://localhost:8080/foobar. I've tried everything that I can think of:

  • Updated the server.xml path value in the Context section

From

<Context docBase="foobar" path="/foobar" reloadable="true" source="org.eclipse.jst.j2ee.server:foobar"/></Host>

To

<Context docBase="foobar" path="/app" reloadable="true" source="org.eclipse.jst.j2ee.server:foobar"/></Host>

I know that I can simply rename the project, but I don't want to.

Here are my Server settings within Eclipse.

EDIT:

I also should mention that I have some db settings in the application context. I am unsure if this should be set to foobar.xml or app.xml..? Eclipse automatically creates an app.xml file in conf/Catalina/localhost, but it seems to be ignored after I make changes.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  1. In project properties click on Web Project Settings (assuming you are in a dynamic web project.) The only configuration value there is "Context root:"
  2. change "Context root" to /app
  3. rebuild
  4. remove the project from tomcat
  5. redeploy.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...