struts2中怎样将参数放入session范围内?
  是那个对象的那个方法?
帮忙给出代码。

解决方案 »

  1.   

    一个Action类可以实现 SessionAware接口
    然后再这个类中定义一个私有的private Map session;
    生成setter与getter方法    /**
         * @return Returns the session.
         */
        public Map getSession() {
            return session;
        }    /**
         * @param session The session to set.
         */
        public void setSession(Map session) {
            this.session = session;
        }这个getSession方法一定要有,这样在你的类中就可以直接使用session了
      

  2.   

    Action里面ActionContext actionContext = ActionContext.getContext();Map session = actionContext.getSession();session.put("USER_NAME", "Test User");