当前位置: 首页>>代码示例>>Java>>正文


Java ActionContext.getSession方法代码示例

本文整理汇总了Java中com.opensymphony.xwork2.ActionContext.getSession方法的典型用法代码示例。如果您正苦于以下问题:Java ActionContext.getSession方法的具体用法?Java ActionContext.getSession怎么用?Java ActionContext.getSession使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.opensymphony.xwork2.ActionContext的用法示例。


在下文中一共展示了ActionContext.getSession方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createExtraContext

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
protected Map createExtraContext() {
    Map newParams = createParametersForContext();

    ActionContext ctx = new ActionContext(stack.getContext());
    PageContext pageContext = (PageContext) ctx.get(ServletActionContext.PAGE_CONTEXT);
    Map session = ctx.getSession();
    Map application = ctx.getApplication();

    Dispatcher du = Dispatcher.getInstance();
    Map<String, Object> extraContext = du.createContextMap(new RequestMap(req),
            newParams,
            session,
            application,
            req,
            res);

    ValueStack newStack = valueStackFactory.createValueStack(stack);
    extraContext.put(ActionContext.VALUE_STACK, newStack);

    // add page context, such that ServletDispatcherResult will do an include
    extraContext.put(ServletActionContext.PAGE_CONTEXT, pageContext);

    return extraContext;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:25,代码来源:ActionComponent.java

示例2: createNewTopic

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
public String createNewTopic(){
	
	ActionContext actionContext = ActionContext.getContext();
    Map session = actionContext.getSession();
    
    AcctUser user=(AcctUser)session.get("user");
    if(user==null){
    	return "login";
    }
	
	 List filters = new ArrayList();
	 PropertyFilter filter = new PropertyFilter("EQL_section.id", SECTIONID);
        filters.add(filter);
        nodes = bbsManager.findAllNodesByFitler(filters);
        
	for(Node n:nodes){
		System.out.println(n.getName());
	}
	
	return "createNewTopic";
}
 
开发者ID:muzili90,项目名称:SpringBBS,代码行数:22,代码来源:TopicAction.java

示例3: doIntercept

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
@Override
protected String doIntercept(ActionInvocation invocation) throws Exception {
	
	ActionContext actionContext = invocation.getInvocationContext();
	Map<String, Object> session = actionContext.getSession();
	
	Admin admin = (Admin) session.get("admin");
	if (admin != null) {
		return invocation.invoke();
	}
	actionContext.put("notice", "您还未登录,无法获得管理员权限");
	return Action.LOGIN;
	
}
 
开发者ID:RyougiChan,项目名称:NewsSystem,代码行数:15,代码来源:AdminLoginInterceptor.java

示例4: intercept

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
@Override
public String intercept(ActionInvocation invocation) throws Exception {
	// ��ȡActionContext
	ActionContext context = invocation.getInvocationContext();
	// ��ȡMap���͵�session
	Map<String, Object> session = context.getSession();
	// �ж��û��Ƿ��¼ 
	if(session.get("admin") != null){
		// ����ִ�з���
		return invocation.invoke();
	}
	// ���ص�¼
	return BaseAction.USER_LOGIN;
}
 
开发者ID:java-scott,项目名称:java-project,代码行数:15,代码来源:UserLoginInterceptor.java

示例5: intercept

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
@Override
public String intercept(ActionInvocation invocation) throws Exception {
	ActionContext context = invocation.getInvocationContext();// ��ȡActionContext
	Map<String, Object> session = context.getSession();// ��ȡMap���͵�session
	if(session.get("customer") != null){// �ж��û��Ƿ��¼ 
		return invocation.invoke();// ����ִ�з���
	}
	return BaseAction.CUSTOMER_LOGIN;// ���ص�¼
}
 
开发者ID:java-scott,项目名称:java-project,代码行数:10,代码来源:CustomerLoginInteceptor.java

示例6: intercept

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
public String intercept(ActionInvocation invocation) throws Exception {
    LOG.debug("Clearing HttpSession");

    ActionContext ac = invocation.getInvocationContext();
    Map session = ac.getSession();
 
    if (null != session) {
        session.clear();
    }
    return invocation.invoke();
}
 
开发者ID:txazo,项目名称:struts2,代码行数:12,代码来源:ClearSessionInterceptor.java

示例7: resolveModel

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
protected Object resolveModel(ObjectFactory factory, ActionContext actionContext, String modelClassName, String modelScope, String modelName) throws Exception {
    Object model;
    Map<String, Object> scopeMap = actionContext.getContextMap();
    if ("session".equals(modelScope)) {
        scopeMap = actionContext.getSession();
    }
    
    model = scopeMap.get(modelName);
    if (model == null) {
        model = factory.buildBean(modelClassName, null);
        scopeMap.put(modelName, model);
    }
    return model;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:15,代码来源:ScopedModelDrivenInterceptor.java

示例8: updateAndDelete

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
@Override
public void updateAndDelete(int id) {
	
	ActionContext actionContext = ActionContext.getContext();
   	Map<String, Object> session = actionContext.getSession();
   	String select=(String) session.get("select");
   	String message=(String) session.get("message");

   	Connection conn=null;
   	
   	String sql=null;
   	
   	
   	if(!message.equals("")){
   	if(select.equals("id")){
   		try{
   		  			
       		conn=getConnection();
       		     	   
       		sql="UPDATE `scada`.`meet_room` SET `useful`='����' WHERE `meetroom_id`="+"'"+id+"'";

               PreparedStatement ps = (PreparedStatement) conn.prepareStatement(sql);
   		        
       		ps.executeUpdate();
       		    
       	    //MeetManager meetManager=(MeetManager)this.getSessionFactory().openSession().get(MeetManager.class, id);
       		//this.getHibernateTemplate().delete(meetManager);
       		//this.getSessionFactory().openSession().close();
       		conn.close();
       		conn=null;
       		System.out.println(conn);
       		
   		}catch(Exception e){
   			System.out.println(e);		
   	     }
   	}
   		
   }
  }
 
开发者ID:bjut-2014,项目名称:scada,代码行数:40,代码来源:MeetManagerDaoImpl.java

示例9: delete

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
@Override
public void delete(String mess){
	ActionContext actionContext = ActionContext.getContext();
   	Map<String, Object> session = actionContext.getSession();
   	String select=(String) session.get("select");
   	String message=(String) session.get("message");
   	int id =Integer.valueOf(mess);
	/*
	Connection conn=null;
    String sql=null;
       try{	
		conn=getConnection();
		
	    sql="DELETE FROM `big_project`.`meet_manager` WHERE `meet_id`="+"'"+id+"'";        
           PreparedStatement ps = (PreparedStatement) conn.prepareStatement(sql);
           ps.executeUpdate();
           conn.close();
           conn=null;
    }catch(Exception e){
	    //e.printStackTrace();
    }
    */
       if(!message.equals("")){
       	if(select.equals("id")){
       		try{
       			MeetManager meetManager=(MeetManager)this.getSessionFactory().openSession().get(MeetManager.class, id);
       		    this.getHibernateTemplate().delete(meetManager);
       		    this.getSessionFactory().openSession().close();
     
       		}catch(Exception e){
       			System.out.println(e);		
       		}
       	}
       	}
}
 
开发者ID:bjut-2014,项目名称:scada,代码行数:36,代码来源:MeetManagerDaoImpl.java

示例10: info

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
public String info(){
	
	ActionContext actionContext = ActionContext.getContext();
    Map session = actionContext.getSession();
    
    AcctUser sessionUser=(AcctUser)session.get("user");
    if(sessionUser==null){
    	return "login";
    }
    
	badges=bbsManager.getAllBadges();
	return "info";
}
 
开发者ID:muzili90,项目名称:SpringBBS,代码行数:14,代码来源:BadgeAction.java

示例11: resetPasswordForm

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
public String resetPasswordForm(){
	
	ActionContext actionContext = ActionContext.getContext();
    Map session = actionContext.getSession();
    
    AcctUser user=(AcctUser)session.get("user");
    if(user==null){
    	return "login";
    }
    
    username=user.getLoginName();
    
    return "resetPassword_form";
}
 
开发者ID:muzili90,项目名称:SpringBBS,代码行数:15,代码来源:UserAction.java

示例12: doIntercept

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
protected String doIntercept(ActionInvocation actionInvocation) throws Exception {
    ActionProxy proxy = actionInvocation.getProxy();
    String name = getBackgroundProcessName(proxy);
    ActionContext context = actionInvocation.getInvocationContext();
    Map session = context.getSession();
    HttpSession httpSession = ServletActionContext.getRequest().getSession(true);

    Boolean secondTime  = true;
    if (executeAfterValidationPass) {
        secondTime = (Boolean) context.get(KEY);
        if (secondTime == null) {
            context.put(KEY, true);
            secondTime = false;
        } else {
            secondTime = true;
            context.put(KEY, null);
        }
    }

    //sync on the real HttpSession as the session from the context is a wrap that is created
    //on every request
    synchronized (httpSession) {
        BackgroundProcess bp = (BackgroundProcess) session.get(KEY + name);

        if ((!executeAfterValidationPass || secondTime) && bp == null) {
            bp = getNewBackgroundProcess(name, actionInvocation, threadPriority);
            session.put(KEY + name, bp);
            performInitialDelay(bp); // first time let some time pass before showing wait page
            secondTime = false;
        }

        if ((!executeAfterValidationPass || !secondTime) && bp != null && !bp.isDone()) {
            actionInvocation.getStack().push(bp.getAction());

final String token = TokenHelper.getToken();
if (token != null) {
	TokenHelper.setSessionToken(TokenHelper.getTokenName(), token);
            }

            Map results = proxy.getConfig().getResults();
            if (!results.containsKey(WAIT)) {
            	LOG.warn("ExecuteAndWait interceptor has detected that no result named 'wait' is available. " +
                        "Defaulting to a plain built-in wait page. It is highly recommend you " +
                        "provide an action-specific or global result named '{}'.", WAIT);
                // no wait result? hmm -- let's try to do dynamically put it in for you!

                //we used to add a fake "wait" result here, since the configuration is unmodifiable, that is no longer
                //an option, see WW-3068
                FreemarkerResult waitResult = new FreemarkerResult();
                container.inject(waitResult);
                waitResult.setLocation("/org/apache/struts2/interceptor/wait.ftl");
                waitResult.execute(actionInvocation);

                return Action.NONE;
            }

            return WAIT;
        } else if ((!executeAfterValidationPass || !secondTime) && bp != null && bp.isDone()) {
            session.remove(KEY + name);
            actionInvocation.getStack().push(bp.getAction());

            // if an exception occured during action execution, throw it here
            if (bp.getException() != null) {
                throw bp.getException();
            }

            return bp.getResult();
        } else {
            // this is the first instance of the interceptor and there is no existing action
            // already run in the background, so let's just let this pass through. We assume
            // the action invocation will be run in the background on the subsequent pass through
            // this interceptor
            return actionInvocation.invoke();
        }
    }
}
 
开发者ID:txazo,项目名称:struts2,代码行数:77,代码来源:ExecuteAndWaitInterceptor.java

示例13: save

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
@Override
public void save() {
	
	Connection conn=null;
	try {  
		ActionContext actionContext = ActionContext.getContext();
    	Map<String, Object> session = actionContext.getSession();

    	String []file=new String[10];

    	/*****************************************************/
		file[0]=(String) session.get("meet_id");
		file[1]=(String) session.get("meet_name");
		file[2]=(String) session.get("meet_title");
		file[3]=(String) session.get("meet_content");
		file[4]=(String) session.get("people_num");		
		file[5]=(String) session.get("start_end");
		file[6]=(String) session.get("location");
		file[7]=(String) session.get("meetroom_num");			
		file[8]=(String) session.get("useful_time");
		file[9]=(String) session.get("room_size");
		int meet_id=Integer.valueOf(file[0]);
		int people_num=Integer.valueOf(file[4]);
		int meetroom_num=Integer.valueOf(file[7]);
		int room_size=Integer.valueOf(file[9]);
		/*****************************************************/

		conn=getConnection();

		String sql=
           "INSERT INTO `scada`.`meet_manager` (`meet_id`, `meet_name`, `meet_title`, `meet_content`, `people_num`, `start_end`, `location`, `meetroom_num`, `useful_time`, `room_size`) "
		+ "VALUES ("+"'"+meet_id+"', '"+file[1]+"', '"+file[2]+"', '"+file[3]+"', '"+people_num+"', '"+file[5]+"', '"+file[6]+"', '"+meetroom_num+"', '"+file[8]+"', '"+room_size+"');";
		PreparedStatement ps = (PreparedStatement) conn.prepareStatement(sql);
		int row = ps.executeUpdate();  
           
           if(row > 0) 
                  System.out.println("�ɹ������" + row + "������"); 
           
		
		conn.close();
		conn=null;
		
	}catch(Exception e){
		e.printStackTrace();
	}
	
}
 
开发者ID:bjut-2014,项目名称:scada,代码行数:48,代码来源:MeetManagerDaoImpl.java

示例14: info

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
public String info(){

ActionContext actionContext = ActionContext.getContext();
   Map session = actionContext.getSession();
   
   AcctUser sessionUser=(AcctUser)session.get("user");
   if(sessionUser==null){
   	return "login";
   }
   
   //��Ҫget ohers��
   user=accountManager.findUserById(sessionUser.getId());
   
   Iterator<AcctUserInfo> it = user.getAcctUserInfo().iterator();  
   while(it.hasNext()) {  
   	userInfo=it.next();
   }  
   if(userInfo.getBirthday()==null||userInfo.getBirthday().trim().equals("")){
   	System.out.println("birthday is null");
   }else{
   	System.out.println("----------\n"+userInfo.getBirthday());
   	String[] birthday=new String[2];
    birthday=MyStringUtil.getBirthdayYMD(userInfo.getBirthday());
    birthdayYear=birthday[0];
    birthdayMonth=birthday[1];
    birthdayDay=birthday[2];
   }
   
   if(userInfo.getAddress()==null||userInfo.getAddress().trim().equals("")){
   	System.out.println("address is null");
   }else{
   	System.out.println("----------\n"+userInfo.getAddress());
   	String[] addresses=new String[2];
	    addresses=MyStringUtil.getAddressSCQ(userInfo.getAddress());
	    provinces=addresses[0];
	    city=addresses[1];
	    district=addresses[2];
   }
   
   //��ʾ�û�ȫ��ѫ��
   badges=user.getBadges();
   
   try{
   	
   	rank=accountManager.getUserRankBySql(sessionUser.getId());
   	
   }catch(Exception ex){
   	ex.printStackTrace();
   }
   
   
return "InfoSuccess";
}
 
开发者ID:muzili90,项目名称:SpringBBS,代码行数:54,代码来源:UserinfoAction.java

示例15: saveTopic

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
public String saveTopic(){
	
	ActionContext actionContext = ActionContext.getContext();
    Map session = actionContext.getSession();
    
    AcctUser user=(AcctUser)session.get("user");
    
    if(user==null){
    	return "login";
    }
    
    Long nodeId=Long.valueOf(nodeValue);
    
    Node node=bbsManager.getNode(nodeId);
    
    Topic newTopic=new Topic();
    newTopic.setAcctuser(user);
    newTopic.setNode(node);
    newTopic.setCommentCount(0L);
    newTopic.setTitle(topic.getTitle());
    //�滻��������
    newTopic.setContent(MyStringUtil.strReplaces(topic.getContent(), "<p>","</p>","<code>","<pre>","</pre>","<code class=\"lang-java\">"));
    newTopic.setCreateTime(new Date());
    newTopic.setStatus(0);
    newTopic.setViewCount(0L);
    
    System.out.println(node.getName());
    System.out.println(user.getLoginName());
    System.out.println(topic.getTitle());
    
    System.out.println(topic.getContent());
    
    bbsManager.saveTopic(newTopic);
    
    //�����������Ӿ���
    user=accountManager.getUser(user.getId());
	long experience=user.getExperience();
	experience+=5;
	
	List<CommunityLevel> bbsLevels=bbsManager.getAllCommunityLevels();
	try {
		CommunityLevel newLevel=LevelUtil.getNewLevel(bbsLevels, experience);
		user.setExperience(experience);
		user.setUser_level(newLevel.getLevels());
		accountManager.saveUser(user);
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
    //-------------
    
	return "save_ok";
}
 
开发者ID:muzili90,项目名称:SpringBBS,代码行数:54,代码来源:TopicAction.java


注:本文中的com.opensymphony.xwork2.ActionContext.getSession方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。