如何正确地将JSP放在WEB-INF文件夹中? [英] How to properly put JSPs in the WEB-INF folder?

查看:183
本文介绍了如何正确地将JSP放在WEB-INF文件夹中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是如何以正确的方式将所有JSP文件放在 WEB-INF / JSP / 中?

My question is how to put all the JSP files in WEB-INF/JSP/ in the proper manner?

是否有任何配置,因为我所知道的结构是:

Is there any configuration for this as the structure I'm aware of is:

WEB-INF / JSP        --> all jsp is reside in that folder 
        / CLASSES    -- all classes is reside that folder
        / LIB        --> library file reside in that folder 

如何根据规范正确设置它。请帮我解决这个问题。

How do I set this up properly according to the spec. Please help me with an answer for this.

推荐答案

根据J2EE规范它不是标准做法或有效(我知道使用像Struts这样的大多数Java Web开发框架,Spring MVC,Stripes你可以做到这一点)。根据规范,我们所有可公开访问的页面都应该在 WEB-INF 之外。但是,如果您希望页面位于 web-inf 中,您可以做的是沿着控制器servlet的行创建一个servlet,并将请求转发给jsp页面。你的servlet和那些页面可以在 WEB-INF 中,并且没有特殊的配置可以做到这一点。

Its not a standard practice or valid as per the J2EE spec (I know using most of the java Web development frameworks like Struts, Spring MVC, Stripes you can do this). As per the spec, all our publicly accessibly pages should be out side of WEB-INF. But if you want the pages to be in web-inf, what you can do is to create a servlet along the lines of a controller servlet and forward the requests to jsp pages from your servlet and those pages can be in WEB-INF, and there is no special configuration that can be done to do this.

这篇关于如何正确地将JSP放在WEB-INF文件夹中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆