标签:
<!--在shiroFilter 中加入一下配置-->
<init-param> <param-name>targetFilterLifecycle</param-name> <param-value>true</param-value> </init-param>
<!--shiroFilter配置 -->
<filter> <filter-name>shiroFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <init-param> <param-name>targetFilterLifecycle</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>shiroFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
ServletContext context = session.getServletContext();
String path = context.getRealPath("upload");
String fileName = file.getOriginalFilename();
System.out.println(path);
File targetFile = new File(path, fileName);
if(!targetFile.exists()){
targetFile.mkdirs();
}
使用shiro安全框架上传文件时用HttpSession获取ServletContext为null问题解决方法。
标签:
原文地址:http://www.cnblogs.com/zealer/p/5723354.html