如何在 Netbeans 中调试 Java Web 应用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2168301/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to debug Java Web Application in Netbeans?
提问by Yatendra Goel
I have debug Java Desktop Applications various times in Netbeans but haven't debug Java Web Application ever.
我曾多次在 Netbeans 中调试 Java 桌面应用程序,但从未调试过 Java Web 应用程序。
I tried to debug it the same way, but it's not working.
我试图以同样的方式调试它,但它不起作用。
I have made an index.html webpage. There is a "form" on that page. After a user submits the form, the request goes to a servlet (say serv1). The servlet has been called but it is showing unexpected results.
我制作了一个 index.html 网页。该页面上有一个“表格”。用户提交表单后,请求将转到 servlet(比如 serv1)。servlet 已被调用,但显示出意外结果。
So to debug it, I put a breakpoint in the servlet class (serv1) and then debug the application.
所以为了调试它,我在 servlet 类 (serv1) 中放置了一个断点,然后调试应用程序。
But when I submitted the form, the control didn't stop at the breakpoint. I am sure that the line at which the breakpoint is set is being called.
但是当我提交表单时,控件并没有停在断点处。我确定正在调用设置断点的行。
Is there any thing I am missing?
有什么我想念的吗?
==================EDITED===================================================
==================编辑================================ ====================
Yes, I had started the server in debug mode. I am using Apache Tomcat 6.0.20
是的,我已经在调试模式下启动了服务器。我正在使用 Apache Tomcat 6.0.20
采纳答案by Pascal Thivent
How did you start your web application in debug mode? On my machine, I simply select the project, click on the Debugtop menu, then Debug Project, select a Server(GlassFish, WebLogic, Tomcat) if required and things just work (I can place a breakpoint in a Servlet and the execution stops there). Tested with all the mentioned containers.
您是如何在调试模式下启动 Web 应用程序的?在我的机器上,我只需选择项目,单击Debug顶部菜单,然后单击Debug Project,如果需要,选择一个服务器(GlassFish、WebLogic、Tomcat)并且一切正常(我可以在 Servlet 中放置一个断点,然后执行停止那里)。使用所有提到的容器进行测试。
回答by Frank Orellana
Also sometimes, I don't know why the project detaches itself from the debugger process, you just need to select the menu Debug -> Attach Debugger and attach the project again. For example in Glassfish just put localhost as the server and 9009 as the port and it will work again
另外有时,我不知道为什么项目会与调试器进程分离,您只需要选择菜单 Debug -> Attach Debugger 并再次附加项目。例如,在 Glassfish 中,只需将 localhost 作为服务器,将 9009 作为端口,它就会再次工作