请问一下大佬们啊,spring_shiro _ test

图片说明
我在ssm+shiro的中 spring test测试想要注入httpservletRequest 但是不知道怎么注入
图片说明

图片说明
这种方法试过了

@Autowired 也试过了

怎么注入???

我们项目我看了看是在fileter类中封装到model类里

 public class CommonUtils {
    private CommonUtils(){
    }

    private static ThreadLocal<HttpServletRequest> requestThreadLocal = new ThreadLocal<HttpServletRequest>();
 public class CommonFilter implements Filter {

    private FilterConfig filterConfig = null;

    public void init(FilterConfig filterConfig) throws ServletException {
        this.filterConfig = filterConfig;
    }

    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        CommonUtils.setRequest((HttpServletRequest) servletRequest);
        filterChain.doFilter(servletRequest,servletResponse);
    }

    public void destroy() {
        CommonUtils.removeCommon();
    }
}

获取的时候,直接用CommonUtils的get方法获取,你可以试一试

在方法的入参中添加httpServletRequest 就可以获取request了