简体   繁体   English

如何使用Eclipse附加JSP调试源

[英]How to attach sources for JSP debugging with eclipse

I am able to set breakpoints and debug JSP files in eclipse (see this post Debug JSP from eclipse ) 我可以在eclipse中设置断点并调试JSP文件(请参阅从Eclipse调试JSP这篇文章)

The problem is I don't know how to attach the JSP source files so that I can see where debugger is stepping. 问题是我不知道如何附加JSP源文件,以便我可以看到调试器在哪里。

I have tried the following things with no success: 我尝试了以下操作,但均未成功:

  • add the maven project as source to the debug configuration 将maven项目作为源添加到调试配置
  • Add the dynamic project nature to the project 将动态项目性质添加到项目中
  • zip all jsps in a jar (like regular java sources) 将所有jsps压缩到一个jar中(就像常规的Java源代码一样)

I don't know what eclipse is really expecting as artifact containing the JSP source files. 我不知道什么是包含JSP源文件的工件真正期望的蚀。

PS: I use Weblogic 10 and maven. PS:我使用Weblogic 10和Maven。

Put a debug point on jsp page, start server in debug mode. 在jsp页面上放置一个调试点,以调试模式启动服务器。 When the debug point is hit, you can examine the variables. 当调试点被击中时,您可以检查变量。 You need to manually open the jsp page to see what is the exact code. 您需要手动打开jsp页面以查看确切的代码。 But that is good enough for me. 但这对我来说已经足够了。

And you shouldn't. 而且你不应该。 You must not have java code within JSP files. JSP文件中不得包含Java代码。 They are only for rendering the view, so no processing there. 它们仅用于渲染视图,因此在那里不进行处理。 Do that in a servlet. 在servlet中执行此操作。 See this extensive answer for why and how to do that. 有关为什么以及如何执行此操作,请参见此广泛的答案

Technically, you can attach the sources generated by your servlet container (in tomcat they are generated in the work directory), but you'd better fix things and move the logic to servlets and debug it there. 从技术上讲,您可以附加由servlet容器生成的源(在tomcat中它们在work目录中生成),但是最好将其修复并将逻辑移至servlet并在那里进行调试。

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

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