J'utilise Spring Web Flow (version 1.0.5) et j'ai une page JSP qui fait un appel AJAX à un flux et qui doit être lue dans les résultats XML. Ce flux définit avec succès un objet dans le FlowScope, puis appelle une page JSP pour afficher les résultats. Dans la page JSP, je voudrais tester si l'objet a une propriété (par exemple, .firstName) et si oui, faire quelque chose. Je peux accéder à la variable dans le FlowScope en utilisant le langage d'expression JSTL (en disant $ {userObj}), mais cela me permet de le cracher. J'ai essayé les méthodes ci-dessous pour y arriver et mettre la logique autour, avec un succès variable.Accéder à FlowScope à partir de JSP sans JSTL
Mise à jour: La question restante est: Comment obtenir le contexte et l'étendue de flux dans la section scriptlet (<%%>)?
<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>