NetBeans 和 Tomcat 虚拟主机

发布于 2024-09-05 02:03:13 字数 660 浏览 9 评论 0原文

首先我要说的是,我是 Java/JSP Web 开发的新手,所以我可能完全错过了一些简单的东西。如果是这样,我提前道歉。

基本上,我想做的是将 Tomcat 中的本地开发站点设置为单独的虚拟主机,类似于我过去设置 Apache 虚拟主机的方式。我讨厌使用 http://localhost:8080/mywebapp 访问本地开发站点。在 Tomcat 中,我在 server.xml 中添加了一个新的 Host 元素,并修改了我的 Windows 主机文件,以便现在我可以使用 url http://mywebapp:8080 访问我的网站,这正是我想要什么。到目前为止,一切都完美无缺。

当我尝试使用 NetBeans 6.8 JSP 项目在站点上工作时,问题就出现了。 NetBeans 坚决使用 http://localhost:8080/mywebapp,无论我在通过它调试或运行站点时做什么。我找不到任何地方可以更改网站在任何“属性”菜单中应使用的 URL。有谁知道如何更改此设置或我在此过程中可能错过的任何内容?当我在 NetBeans 中设置 PHP 项目时,它允许我输入要运行站点的 URL,并通过项目属性对其进行更改。

再说一次,JSP 开发和 Tomcat 对我来说还是很陌生的,但在过去几年使用 ASP.NET 后,我非常渴望开始制作 JSP 网站。谢谢!

Let me start out by saying that I am new to Java/JSP web development, so I may have totally missed something simple. If so, I apologize for it in advance.

Basically, what I am trying to do is setup local development sites in Tomcat as a separate Virtual Host, similiar to how I have setup Apache Virtual Hosts in the past. I hate accessing a local dev site using http://localhost:8080/mywebapp. In Tomcat, I have added a new Host element in the server.xml and modified my Windows hosts file so that now I can access my site with the url http://mywebapp:8080, which is exactly what I want. Everything works flawless to this point.

The problem starts when I try to use a NetBeans 6.8 JSP project to work on the site. NetBeans is dead set on using http://localhost:8080/mywebapp no matter what I do when I debug or run the site through it. I cannot find anywhere to change what url the site should use in any of the Properties menus. Does anyone know how to change this or anything I may have missed along the way? When I set up PHP projects in NetBeans it allows me to enter the url I want to run the site from and to change it through the project properties.

Again, JSP development and Tomcat are very new to me, but I am very anxious to get started making JSP sites after working with ASP.NET for the past few years. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等风来 2024-09-12 02:03:14

我终于明白了,好吧,我明白了它足以为我工作。为了让 Netbeans 看到我想要的服务器,您必须在“添加服务器”对话框中创建一个新服务器,并为其指定与默认 Catalina 基础不同的路径。然后,在设置项目时,将上下文路径设置为空,现在站点将以 http://localhost:8080 运行,而不是 http://localhost:8080/xxxxx。虽然这并不完全是我想要的,但它目前对我有用。

I finally figured it out, well, I figured it out enough to work for me. To make Netbeans see the servers as I want, you have to create a new server in the Add Server dialog and give it a different path than the default Catalina base. Then, when setting up the project, set the context path to nothing and now the site will be run as http://localhost:8080 and not http://localhost:8080/xxxxx. While this isn't exactly what I wanted, it does work for me for now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文