tomcat 的 URL 问题包括项目名称 [英] URL issue with tomcat include project name

查看:25
本文介绍了tomcat 的 URL 问题包括项目名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 Eclipse 用于 J2EE 项目...一台设备向我发送请求和

I am using Eclipse for J2EE project... one device send request to my side and url like

http://myIP:myPort/corporationweb/Controller

/corporationweb/Controller 已修复,我们无法更改它,因为它是在设备上制作的

/corporationweb/Controller is fixed we can't change it because it made on device

我在 Eclipse 中的项目名称是VirtualTest",但如果我映射任何 servlet,/corporationweb/Controller URL 像

my project name in eclipse is "VirtualTest" but here tomcat include project name if i mapping any servlet, /corporationweb/Controller URL like

http://localhost:8080/VirtualTest/corporationweb/Controller

我需要在不更改项目名称的情况下打开页面

I need page open without change project name

  • 任何我可以直接映射servlet的URL,如http://localhost:8080/corporationweb/Controller
  • 任何 URL 重写技术..
  • 作为我项目的默认应用程序

推荐答案

在Eclipse中右键单击项目,选择Properties,进入Web Project Settings并设置Context根/.

Rightclick project in Eclipse, choose Properties, go to Web Project Settings and set Context root to /.

这将让 Eclipse 将项目部署到上下文根目录而不是项目名称(这是默认值).

This will let Eclipse deploy the project on context root instead of project name (which is the default).

与具体问题无关,您确实需要确保您的应用程序的编写方式使其不关心应用程序部署在哪个上下文路径上.这是特定于服务器的设置,无法从您的项目内部进行控制.使用 HttpServletRequest#getContextPath() 聪明的方式.

Unrelated to the concrete problem, you really need to ensure that your application is written the way so that it does not care on which context path the application is been deployed. This is namely a server specific setting which is not controllable from inside your project. Make use of HttpServletRequest#getContextPath() the smart way.

这篇关于tomcat 的 URL 问题包括项目名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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