在JSP页面内进行调试? [英] Debugging inside a JSP page?
问题描述
我正在使用Java 1.6,Spring 3.4,Spring Webflow 2.3.2和Tomcat7.我正在尝试调试使用EL表达式的JSP页面,例如:
I'm using Java 1.6, Spring 3.4, Spring Webflow 2.3.2 and Tomcat 7. I'm trying to debug a JSP page which uses EL expressions like:
<c:if test="${myObject.myThing == SomeClass.ENUMVALUE.myvalue}" >
myObject
对象作为Webflow模型对象传递.我在此行上设置了一个断点,可以到达它并中断它,但是我尝试观察"或评估"的任何操作都会给我一条错误消息.我得到
The myObject
object is passed in as the Webflow model object. I have a breakpoint set on this line and I am able to reach it and break on it, but anything I try to "watch" or "evaluate" gives me an error message. I get either
${myObject.myThing == SomeClass.ENUMVALUE.myvalue}: Invalid Expression
myObject.myThing: Type is unknown for 'myObject'
(MyCorrectType) myObject: Cannot find local variable 'myObject'
如何找到该模型对象?到达JSP页面时包含的内容是什么?
How the heck can I find this model object? What is it contained in by the time it reaches the JSP page?
推荐答案
答案是,它将位于org.apache.catalina.connector.Request
对象中(在我的特定情况下,它被埋在包装对象的深处.)
The answer turned out to be that it will be in the org.apache.catalina.connector.Request
object (In my particular case, it was buried several levels deep inside wrapper objects.)
如果您正在使用调试器,例如Intellij中的调试器(我使用的调试器),则可以通过对表达式request.getAttribute("attributeName")
求值来获取单个属性的值(例如Webflow模型对象).请注意,这可能会返回Java Object类型,并且您可能必须将其强制转换为正确的类型.
If you are using a debugger, like the one in Intellij (which I use), you can get the value of an individual attribute (like the Webflow model object) by evaluating the expression request.getAttribute("attributeName")
. Note that this may return a Java Object type, and you may have to cast it to the correct type.
例如,对于我来说,我可以使用以下表达式找到所需的值:
For example, in my case, I was able to find the value of the value I wanted using this expression:
((MyObject)(request.getAttribute("myObject"))).getMyThing()
我希望这对某人有帮助.
I hope this helps somebody.
这篇关于在JSP页面内进行调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!