11

Tomcat访问webapp下的WEB-INF文件中的html和jsp文件

 3 years ago
source link: https://segmentfault.com/a/1190000038662754
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Tomcat访问webapp下的WEB-INF文件中的html和jsp文件

重定向问题

servlet中创建的webapp项目下的WEB-INF文件用来存放web.xml, class文件, jar包,当前项目的核心配置文件等。
其项目的安全级别很高,浏览器这个小菜鸡不能直接访问,只能通过重定向后才可以访问,如果需要直接访问,可以放在和WEB-INF同级目录下。

下面是访问WEB-INF内容的方法:
如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);

就不能访问.

以上方法通过百度和老师的代码总结,但是
hhhh,我的还是不行,我是在WEB-INF中访问HTML文件,访问不了,然后改为.jsp文件,依然访问不了。。。。。哭了


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK