问题描述
有没有人知道如何在 IntelliJ IDEA?
Does anyone know how to debug JSP
in IntelliJ IDEA?
中调试 JSP
我在我的 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应用程序服务器配置。
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可以自动检测该方面(无论如何检查它已经完成),或者您可能需要手动添加。记住在Java EE构建设置选项卡中设置为创建Web面分解目录;如果您不想重复,则只能启用它并指向已存在的目录。
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调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!