Reputation: 28556
I'm using Spring WebFlow together with Spring MVC. When i request page for example http://localhost:8080/testapp/index.html?param=100
WebFlow make redirect to http://localhost:8080/testapp/index.html?execution=e3s1
and can't get param
in jsp, param
lost somewhere. How to get this working ?
Another example of this situation - Spring Security configured like below:
<security:form-login authentication-failure-url="/login.html?loginfail=1" login-page="/login.html" />
When login fail, i can't get loginfail
parameter in login.jsp
.
<c:if test="${!empty param.loginfail}">Login error!</c:if>
I can access request parameters in flow, but... Do i have to set view/flowScope variables for all my request parameters like below ?
<set name="viewScope.loginfail" value="requestParameters.loginfail" />
Upvotes: 3
Views: 8536
Reputation: 550
You can add ie.
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<input name="param" required="true" />
<on-start>
<evaluate expression="someAction.getSomething(param)" result="conversationScope.myParam"/>
</on-start>
...
to your flow process.
Upvotes: 0
Reputation: 1521
To answer your generic question about Spring WebFlow (SWF) and request parameters:
After receiving your first request (that includes the request parameter), Spring WebFlow is sending your browser a 302 redirect which forces another GET. This GET request does not include your original request parameters. Like you noted, you can access these parameters using the requestParameters map in your flow logic. You can then set request parameters on the viewScope or requestScope, but you should ask yourself why you need to get at these request parameters in your JSP.
Is there logic you are performing in your view layer (JSP), that should really be performed in the controller layer (web flow)? Do you need to be binding to a model object (using the model attribute on view-state)?
If you are only dealing with a single parameter, then you are probably ok to just set it in the view or request scope. But if you have several, maybe you need a command object that you can use as your model attribute. SWF would handle binding the parameters to this object, and would expose this object to the view that you are redirected to.
More specifically, regarding Spring Security/login:
It appears that you may be trying to implement your login page as an actual webflow... I would take a look at the SWF documentation, it has a short chapter about securing webflows. The login page/process would not be defined as a state in your flow.
Upvotes: 5