Action类中通过ServletActionContext来获取web资源

2021-06-16 20:03

阅读:725

标签:logs   let   return   package   span   pac   获取   div   success   

1 . 获取方法如下:

package com.xuzhiwen.test;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

public class ServletAction {
    
    public String getServletAction(){
        //request
        HttpServletRequest request = ServletActionContext.getRequest();
        //session
        HttpSession session = request.getSession();
        //servletContext
        ServletContext servletContext = ServletActionContext.getServletContext(); 
        return "success";
    }
}

 

Action类中通过ServletActionContext来获取web资源

标签:logs   let   return   package   span   pac   获取   div   success   

原文地址:http://www.cnblogs.com/beibidewomen/p/7270205.html


评论


亲,登录后才可以留言!