在使用eclipse进行调试时,有没有办法检查特定表达式的值?表达式视图并不总是有用的。
例如:
public class P
{
public boolean executed = false;
public String getSomeString() {
if (!executed) {
executed = true; //set executed to true,so calling this method again will not yield the same result
return "someStr";
}else {
throw new RuntimeException();
}
}
}
这是主要方法:
public class Test {
public static void main(String[] args) {
P p = new P();
p.getSomeString(); //breakpoint here, I want to check the value of this expression, but it is not assign to a variable.
System.out.println();
}
}
当我调试Struts2时,我想出了这个问题。
在Dispatcher#serviceAction()
的正文中,有一行proxy.execute();
,它是来自DefaultActionInvocation#invoke()
的字符串值,基本上是来自Actions的返回字符串。
但proxy.execute();
的值未分配给变量或在Dispatcher#serviceAction()
内的任何位置使用。那么如何从与视图相关联的动作返回String?
答案 0 :(得分:4)
只需在导航中按下Ctrl + Shift + I或“运行”/“检查”即可标记表达式。 或者您可以使用“显示”视图。在这里,您可以编写和存储表达式,您要检查。
答案 1 :(得分:0)
您可以通过鼠标检查任何变量值,或者在选择任何表达式后按CTRL + SHIFT + I。
OR
您可以在调试模式的监视表达式中添加变量。