Wang.J Wang.J - 1 year ago 137
Java Question

How can i get session from spring web flow xml?

i read spring in action 4,but i got confused that the example did't show how to get Session from request.
i want to achieve a complete login flow,i want to get the session from jsp to check if the user exist.
The example just showed requestParameters this class?(i even don't know what it is)
And by using point '.' to get the parameter from Get method.But how can i get a session?
When if the method is Post?

<action-state id="lookupCustomer">
<evaluate result="order.customer"
expression="pizzaFlowActions.lookupCustomer(requestParameters.phoneNumber)" />
<transition to="registrationForm"
on-exception="" />
<transition to="showOrder" />

Answer Source

I think you are talking about spring MVC and Spring is used for dependency injection of the classes which you need in your application.

i) To keep the user object in session, have HttpSession object in parameter for the controller class which should be session scoped and store the session value in user object.

For example:

     public class UserController {
     @RequestMapping(method = RequestMethod.GET)
     public String testMestod(HttpServletRequest request){
     User user=(User)session.getAttribute("cart");
     return "testJsp";

ii) Also make the User Object class as session object by scope

For example:

     public class User
      String user;
      /*  setter getter*/

iii) You can have XML file for further dependency like AOP etc.

For example:

   <beans xmlns=""

    <bean id="user"    class="com.User" scope="session">     
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download