[技术分享]20171130_文件下载 _ excel显示错误

 

  • 原代码是这个样的:
...
...
...
ServletContext servletContext  =  request.getSession().getSevletContext();
String realpath = servletContext.getRealPath("//WEB-INF//pages//template");
File file = new File(realpath+"\\"+filename);
...
...
...

 上面的这段代码在本地环境(tomacat)下是可以正常运行的,但是到了生产环境(was)下就不行了,后来发现,是因为was环境下会把\\解析成_  

  •  后来我修改了代码如下就可以了
...
...
...
ServletContext servletContext  =  request.getSession().getSevletContext();
String realpath = servletContext.getRealPath("//WEB-INF//pages//template//"+filename);
File file = new File(realpath);
...
...
...

 

posted @ 2017-11-30 22:51  一码平天下  阅读(164)  评论(0)    收藏  举报