I'm using spring webflow, but I need to access my HttpSession in a method that's accessed using a transition ==> evaluate expression. (so in the xml file containing my flow) So far I've yet to find a way to actually pass it to my method. I've taken a look at the flowrequestcontext but so far I haven't found a way yet.
相关问题
- How to change default format in StringToDate? Spri
- Spring Web Flow transitions not triggered
- Can I get remove of the 'execution' parame
- how do i show error/info/fatal messages in jsp whe
- trying to add JSF to my Spring WebFlow Project and
相关文章
- Spring Webflow - decision-state vs action-state
- How to pass parameters to spring webflow
- What is setting Cache-Control no-cache, no-store i
- Gracefully handle expired HttpSession in Spring We
- Spring Webflow , Primefaces with Comet (Atmosphere
- Sharing object across screens, using Spring Webflo
- Grails WebFlow State Name
- Bookmarkable URL in JSF application - Trying to us
I had a very similar need to access the
HttpSession
in a flow. Here's how I did it:First, take a look at the
externalContext
special EL variable:externalContext
It gives you one of these:
org.springframework.webflow.context.ExternalContext
The
ExternalContext
interface provides a method calledgetNativeRequest()
, which should return to you anHttpRequest
object. (in weblflow 2.0.x at least)Here is the javadoc: http://static.springsource.org/spring-webflow/docs/2.0.x/javadoc-api/org/springframework/webflow/context/ExternalContext.html#getNativeRequest()
So, that means you should able to craft an expression using something like this:
<evaluate expression="externalContext.nativeRequest.session" result="flowScope.information"/>
As a simple test, you can use an expression like this:
expression="externalContext.nativeRequest.session.id"
to pass your session id to a method.
Of course you can use similar EL to pass the session to methods etc.
I think you don't need to pass it as soon as you pass the RequestContext. You can try this:
to insert object (e.g. from flowScope) into session this worked for me:
This worked for me:
On the client:
Hope it helps!