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

查看:510
本文介绍了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 /控制器是固定的,我们无法更改它,因为它在设备上

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

我的eclipse中的项目名称是 VirtualTest 但是,如果我映射任何servlet,tomcat包含项目名称, / 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中右键单击项目,选择< roperties ,转到 Web项目设置,并将上下文根设置为 /

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天全站免登陆