我为VSCode安装了以下Java扩展:
Red Hat版本0.41.0 https://github.com/redhat-developer/vscode-java
对Java(TM)的语言支持Tomcat for Java版本0.11.1 https://github.com/adashen/vscode-tomcat
用于Java版本0.170 https://github.com/Microsoft/vscode-java-debug
的调试器
复制步骤:
打开项目
将项目构建为.war
在Tomcat服务器上调试.war
设置断点
在浏览器中打开
运行代码时,代码会在断点处停止,我可以逐步执行-但在鼠标悬停在左侧的“变量”窗格中未显示变量/值。
package src.ServletTest;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloServlet extends HttpServlet {
private String msg;
//private static final long serialVersionUID = 1L;
public void init() throws ServletException {
msg = "Hello World!"; ***** I can mouseover and see variable value at this breakpoint
}
//@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
response.setContentType("text/html"); ***** but once inside doGet I cannot see any of these local variable vaules
PrintWriter out = response.getWriter();
String s1 = "Hiya";
String s2 = "Ya!";
String s3 = s1 + s2;
out.println("<html>");
out.println("<head><title>Java Home Page</title></head>");
out.println("<body>");
out.println("<h1>Java says Hi to you!</h1>");
out.println(s3 + msg);