如何在Eclipse中更改动态Web项目的上下文根? [英] How to change context root of a dynamic web project in Eclipse?

查看:304
本文介绍了如何在Eclipse中更改动态Web项目的上下文根?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Eclipse中开发了一个动态Web项目。现在我可以使用以下URL访问浏览器:

  http:// localhost:8080 / MyDynamicWebApp 

现在我想将访问URL更改为

  http:// localhost:8080 / app 

我改变了上下文从项目属性| Web项目设置|上下文根的根。



但它不工作。网络应用程序仍然具有如前所述的访问URL。我已经在Tomcat上重新部署了应用程序,重新启动了Tomcat,并已经完成了所有应该做的工作,但访问URL与以前一样。



I发现$ server.xml 文件附有 WAR 文件。那么Tomcat如何确定我的网络应用程序的上下文根是 / MyDynamicWebApp ,并允许我通过该URL访问应用程序?

解决方案

我相信你现在已经走了,但我以为我会回答。



这些答案中有些提供了解决方法。实际上必须发生的是清理并重新发布项目以激活新的URI。这可以通过右键单击服务器(在服务器视图中)并选择清洁来完成。然后你开始(或重新启动)。这里的大部分其他答案建议您做出有效实现这一点的事情。



正在更改的文件是 workspace / .metadata / .plugins / org.eclipse .wst.server.core / publish / publish.dat ,除非你的工作空间中有多个服务器,在这种情况下,它将在同一路径上发布publishN.dat。



希望这有助于某人。






不知道这是否适合礼节不是 - 我正在编辑这个答案给Eclipse Indigo的确切步骤。


  1. 在项目的属性中,选择Web Project


  2. 将上下文根更改为app。




  3. 选择窗口>显示视图>服务器。


  4. 通过单击红色方框(停止服务器工具提示)停止服务器或上下文单击t他的服务器列表选择停止。


  5. 在要使用的服务器上,单击上下文以选择清除...。




  6. 在此确认对话框中单击确定。




可以使用新的应用程序URL运行应用程序,例如:


http:// localhost:8080 / app /


在Eclipse之外,在您的生产服务器上执行此操作更容易 - >重命名战争档案。将您的Vaadin应用程序导出为WAR文件(文件>导出> Web> WAR文件)。将WAR文件移动到Web服务器的servlet容器(如Tomcat)。将WAR文件重命名为app.war。当您启动servlet容器时,大多数Tomcat将自动部署应用程序,包括将war文件扩展到一个文件夹。在这种情况下,我们应该看到一个名为app的文件夹。你应该很好去测试你的URL对于像example.com这样的域名,这将是:



http://www.example.com/app/



如果使用视觉添加,Vaadin工具包程序员可能需要重新构建其窗口小部件集on。


I have developed a dynamic web project in Eclipse. Now I can access it through my browser using the following URL:

http://localhost:8080/MyDynamicWebApp

Now I want to change the access URL to

http://localhost:8080/app

I changed the context root from the project "Properties | Web Project Settings | Context Root".

But it is not working. The web app still has the access URL as earlier. I have re-deployed the application on Tomcat, re-started the Tomcat and have done everything that should be done, but the access URL is the same as earlier.

I found that there were no server.xml file attached with the WAR file. Then how the Tomcat is determining that the context root of my web app is /MyDynamicWebApp and is allowing me to access the application through that URL?

解决方案

I'm sure you've moved on by now, but I thought I'd answer anyway.

Some of these answers give work-arounds. What actually must happen is that you clean and republish your project to "activate" the new URI. This is done by right-clicking your server (in the Servers view) and choosing Clean. Then you start (or restart it). Most of the other answers here suggest you do things that in effect accomplish this.

The file that's changing is workspace/.metadata/.plugins/org.eclipse.wst.server.core/publish/publish.dat unless, that is, you've got more than one server in your workspace in which case it will be publishN.dat on that same path.

Hope this helps somebody.


Not sure if this is proper etiquette or not -- I am editing this answer to give exact steps for Eclipse Indigo.

  1. In your project's Properties, choose "Web Project Settings".

  2. Change "Context root" to "app".

  3. Choose Window > Show View > Servers.

  4. Stop the server by either clicking the red square box ("Stop the server" tooltip) or context-click on the server listing to choose "Stop".

  5. On the server you want to use, context-click to choose "Clean…".

  6. Click OK in this confirmation dialog box.

Now you can run your app with the new "app" URL such as:

http://localhost:8080/app/

Doing this outside of Eclipse, on your production server, is even easier --> Rename the war file. Export your Vaadin app as a WAR file (File > Export > Web > WAR file). Move the WAR file to your web server's servlet container such as Tomcat. Rename your WAR file, in this case to "app.war". When you start the servlet container, most such as Tomcat will auto-deploy the app, which includes expanding the war file to a folder. In this case, we should see a folder named "app". You should be good to go. Test your URL. For a domain such as "example.com" this would be:

http://www.example.com/app/

Vaadin toolkit programmers may need to rebuild their widget set if using visual add ons.

这篇关于如何在Eclipse中更改动态Web项目的上下文根?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆