IntelliJ IDEA 中的 JSP 调试 [英] JSP debugging in IntelliJ IDEA

查看:141
本文介绍了IntelliJ IDEA 中的 JSP 调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何在IntelliJ IDEA中调试JSP?

Does anyone know how to debug JSP in IntelliJ IDEA?

当我在 JSP 文件中设置断点时,这些断点似乎永远不会生效.调试器永远不会命中它们.IDEA 似乎认为断点是有效的.我确实看到一个红点位于我放置断点的行的左侧.

When I set breakpoint in my JSP files, those breakpoints never seem to take effect. The debugger never hits them. IDEA seems to think that the breakpoints are valid. I do see a red dot placed to the left of the line where I place my breakpoint.

我在 IntelliJ 论坛中阅读了这篇文章> JSP 文件需要在 web-inf 下才能调试工作.

I read in IntelliJ forum in this post that JSP files need to be under web-inf for debugging to work.

但后来我也读到放置在 web-inf 下的 JSP 文件不会被用户直接访问.

But then I also read that JSP files placed under web-inf won't be directly accessible by the user.

我不确定谁是正确的.

推荐答案

对于 Intellij 中的 JSP 调试,有一些必须按顺序进行的配置.Intellij 始终允许您在 JSP 行上添加断点这一事实并不一定意味着您已配置 JSP 调试.下面我指的是 Intellij 8 配置,w.r.t.之前的版本你需要做类似的操作,因为概念是相同的.

For JSP debugging in Intellij there are some configurations that must be in order. The fact that Intellij always allows you to add a breakpoint on a JSP line does not necessarily imply that you’ve configured JSP debugging. In the following I refer to Intellij 8 configuration, w.r.t. previous versions you will need to do similar operations as the concepts are the same.

为了启用 JSP 调试,您必须执行两个步骤:在项目中设置 Web 应用程序配置并添加 Web 应用程序服务器配置.

In order to enable JSP debugging you must do two steps: set a web application configuration in your project and add a web application server configuration.

Web 应用程序配置:为了进行 JSP 调试,您的项目结构中必须有一个web"方面,指向正确的 web.xml 文件.根据您使用的 Web 应用程序结构的类型,Intellij 可能会自动检测到 facet(无论如何都要检查它做了什么),或者您可能必须手动添加它.记得在Java EE build settings"选项卡中设置为可以Create web facet purged directory";如果你不想重复,一个技巧就是启用它并指向你已经存在的目录.

Web application Configuration: in order to have JSP debugging, you must have a "web" facet in your project structure, pointing to the correct web.xml file. Depending on the kind of web application structure you are using, the facet may be detected automatically by Intellij (go anyway to check what it has done) or you may have to add it manually. Remember in the "Java EE build settings" tab to set as anable "Create web facet exploded directory"; if you don’t want duplications, a trick is just to enable it and point to your already existing directory.

(Web) 应用服务器:转到编辑配置",您必须在配置中添加应用服务器,而不是像其他应用程序一样启动 Web 服务器.这样Intellij 就可以拦截JSP 调用了.在应用程序服务器列表中,您应该有默认的 Tomcat.在执行此操作之前,请确保已安装本地 Tomcat,并在添加 Web 应用程序服务器时指向该位置.最后一个技巧是转到部署"选项卡并选择您在上一步中配置的相同方面作为部署源".

(Web) Application server: Go to "edit configurations", there you have to add to configurations an application server, not launch the web server as an application like any other. In this way Intellij will be able to intercept JSP calls. In the list of application servers, you should have the default one, Tomcat. Be sure to have a local Tomcat installation before you do this, and point to that when adding the web application server. The last trick is going to the "Deployment" tab and selecting as "Deployment source" the same facet that you configured in the previous step.

如果您想使用另一个 Web 应用程序服务器,同样的配置也可以工作,我使用最新的 Caucho Resin 版本对其进行了测试,并且调试工作正常(使用之前的 Intellij 和 Resin 组合则不行).

The same configuration works if you want to use another web application server, I tested it with the latest Caucho Resin releases and debugging works fine (it didn’t with the previous Intellij and Resin combinations).

如果在要添加的可用应用服务器列表中没有看到 Tomcat,请检查通用 Intellij 设置窗格中的插件:在最新版本中,越来越多的功能变得可插拔",甚至是非常基本的功能可能会被禁用;这个插件叫做Tomcat集成".

If you don’t see Tomcat in the list of available application servers to add, check the plugins in the general Intellij settings pane: in the latest releases, more and more functionality has become "pluggable", and even very basic functions may be disabled; this plugin is called "Tomcat integration".

最后,JSP文件需要在WEB-INF下才能调试肯定不是真的.

Finally, it is surely not true that JSP files need to be under WEB-INF to be under debugging.

这篇关于IntelliJ IDEA 中的 JSP 调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆