简体   繁体   English

从eclipse调试JSP

[英]debug JSP from eclipse

Does anyone know of a good tool for debugging JSPs from within Eclipse? 有没有人知道从Eclipse中调试JSP的好工具? I'd like to be able to set and watch breakpoints, step through the Java code/tags, etc within Eclipse while the app is running (under JBoss in my case). 我希望能够在应用程序运行时在Eclipse中设置和观察断点,逐步执行Java代码/标记等(在我的情况下,在JBoss下)。

Presumably, it's reasonably straightforward to debug the servlet class that's generated from a JSP, but it's also fairly unappealing. 据推测,调试从JSP生成的servlet类是相当简单的,但它也相当没有吸引力。

If you have WTP installed, you can set breakpoints within a JSP and they work fine in a regular "remote debug" session. 如果安装了WTP ,则可以在JSP中设置断点,并且它们可以在常规“远程调试”会话中正常工作。 However, once you've stopped on a breakpoint, stepping through the code is nigh on impossible and finding whatever it is that you wish to inspect takes a lot of digging around in the "Variables" view. 然而,一旦你在断点处停下来,单步执行代码几乎是不可能的,找到你希望检查的内容需要在“变量”视图中进行大量挖掘。

If you are having to use a debugger in a JSP, chances are very good that you are doing things in the JSP that you shouldn't be. 如果您不得不在JSP中使用调试器,那么您在JSP中做的事情很可能是非常好的。 I recommend that you think very hard about whether your current implementation is using good MVC design practice. 我建议您非常认真地考虑当前的实现是否使用了良好的MVC设计实践。 JSPs really should be about presentation, which should rarely (if ever) require debugging. JSP应该是关于表示的,这应该很少(如果有的话)需要调试。

If you have certain logic constructs that you are having to implement in JSP, consider implementing them using a custom tag (which is easy to debug in an IDE), or do the processing in controller servlet that presents the data in an easy to digest form for the JSP. 如果您有必须在JSP中实现的某些逻辑结构,请考虑使用自定义标记(在IDE中易于调试)实现它们,或者在控制器servlet中进行处理,以易于理解的形式呈现数据对于JSP。

Within Eclipse, you can put breakpoints to your jsp file, step through the Java code/tags, etc. 在Eclipse中,您可以将断点放到jsp文件中,逐步执行Java代码/标记等。
However the only view you can use while debugging is the Variables view to inspect the value of any variable. 但是,调试时可以使用的唯一视图是Variables视图,用于检查任何变量的值。

And one more thing, you can not see the value for example of this expression: 还有一件事,你看不到这个表达式的值:
<%= response.encodeURL("ProcessLogin.jsp") %> <%= response.encodeURL(“ProcessLogin.jsp”) %>
just the value of the variable response . 只是变量响应的值。

Apparently, Eclipse has a troubleshooting page on this, though when I tried it I did get a 404 with it. 显然,Eclipse有一个故障排除页面 ,但是当我尝试它时,我确实得到了404。 Hopefully this can at least get you started in a good direction. 希望这至少能让你开始朝着一个好的方向前进。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM