Я использую Spring Web Flow (v. 1.0.5), и у меня есть страница JSP, которая выполняет AJAX-вызов потока и должна читать результаты XML. Этот поток успешно устанавливает объект в FlowScope, а затем вызывает страницу JSP для отображения результатов. На странице JSP я хотел бы проверить, есть ли у объекта свойство (скажем, .firstName), и если да, сделать что-нибудь. Я могу получить доступ к переменной в FlowScope, используя язык выражений JSTL (говоря $ {userObj}), но это позволяет мне выплюнуть ее. Я попробовал описанные ниже методы, чтобы добиться этого и обдумать логику с переменным успехом.
Обновление. Остается вопрос: как получить контекст и область действия потока в разделе сценариев (<%%>)?
<rootnode>
<!-- Attempt 1: c:if isn't being interpreted (though ${userObj.firstName} is),
it's just displaying the tags on the page. -->
<!-- Update, I didn't have the <%@ taglib directive for jstl/core.
Now I do, and they're being interpreted, but it says
"According to TLD or attribute directive in tag file,
attribute test does not accept any expressions"
How can the if/@test not accept expressions? Isn't that its whole purpose
in life? -->
<!-- Update 2, I also forgot the taglib for the rt language, which is separate,
I guess (jstl/core_rt). <c:if test now works properly. -->
<c:if test="${!empty(userObj.firstName)}">
<test>not empty</test>
</c:if>
<%
/* Attempt 2: This throws an error, can't resolve "context". How do I get the context? */
if (context.getFlowScope().userObj != null) {
out.write("not null");
} else {
out.write("not not null");
}
%>
<!-- Attempt 3: This works, I get the reference to the Object and it
spits out the correct firstName, gives me no control other than
spitting out the value. -->
<userReference>${userObj}</userReference>
<userReference_firstName>${userObj.firstName}</userReference_firstName>
</rootnode>