Commit 67d804aa by WeiCong

修复was服务器与tomcat不同

parent e8cde8e0
...@@ -31,9 +31,9 @@ public class ResourceAccessFilter implements Filter { ...@@ -31,9 +31,9 @@ public class ResourceAccessFilter implements Filter {
HttpServletRequest request = (HttpServletRequest) req; HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res; HttpServletResponse response = (HttpServletResponse) res;
String uri = request.getRequestURI(); String uri = request.getRequestURI();
String servletPath = request.getServletPath(); String pdfres;
if (needPdfsFilter(servletPath)) { if ((pdfres=needPdfsFilter(uri))!=null) {
if (!doPdfsFilter(servletPath, request, response)) { if (!doPdfsFilter(uri,pdfres, request, response)) {
return; return;
} }
} else if (isExcludeRes(uri)) { } else if (isExcludeRes(uri)) {
...@@ -43,12 +43,12 @@ public class ResourceAccessFilter implements Filter { ...@@ -43,12 +43,12 @@ public class ResourceAccessFilter implements Filter {
chain.doFilter(req, res); chain.doFilter(req, res);
} }
} catch (Throwable b) { } catch (Throwable b) {
log.warn("资源访问过滤器执行异常:" + b.getMessage()); log.warn("资源访问过滤器执行异常");
chain.doFilter(req, res); chain.doFilter(req, res);
} }
} }
private boolean doPdfsFilter(String uri, HttpServletRequest request, HttpServletResponse response) throws Exception { private boolean doPdfsFilter(String uri,String pdfres, HttpServletRequest request, HttpServletResponse response) throws Exception {
String[] parts = uri.split("_"); String[] parts = uri.split("_");
if (parts.length != 3) { if (parts.length != 3) {
log.warn("Access Pdfs Forbidden"); log.warn("Access Pdfs Forbidden");
...@@ -67,6 +67,7 @@ public class ResourceAccessFilter implements Filter { ...@@ -67,6 +67,7 @@ public class ResourceAccessFilter implements Filter {
return forbiddenPdf(request, response); return forbiddenPdf(request, response);
} }
} }
res=res.substring(res.indexOf(pdfres),res.length());
pdfWriter(request.getSession().getServletContext().getResourceAsStream(res), response); pdfWriter(request.getSession().getServletContext().getResourceAsStream(res), response);
return false; return false;
} }
...@@ -94,13 +95,13 @@ public class ResourceAccessFilter implements Filter { ...@@ -94,13 +95,13 @@ public class ResourceAccessFilter implements Filter {
return true; return true;
} }
private boolean needPdfsFilter(String uri) { private String needPdfsFilter(String uri) {
for (String pdf : pdfpth) { for (String pdf : pdfpth) {
if (uri.startsWith(pdf)) { if (uri.contains(pdf)) {
return true; return pdf;
} }
} }
return false; return null;
} }
private boolean isExcludeRes(String uri) { private boolean isExcludeRes(String uri) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment