web-inf下文件访问

应用服务器把WEB-INF指为禁访目录,即直接在浏览器里是不能访问的.
因此,可以让servlet进行访问,如web-inf下有a.jsp则可以用request.getrequestdispatcher("/web-inf/a.jsp").forward(request,response);进行派遣访问.
但如果web-inf下有a.htm,则用request.getrequestdispatcher("/web-inf/a.htm").forward(request,response);就不能访问.

通过请求转发可以访问web-inf下的jsp,而重定向的话不行;

猜你喜欢

转载自www.cnblogs.com/doveshelly/p/9251568.html