来自 WEB-INF 文件夹的 web.xml 欢迎文件 [英] web.xml welcome file from WEB-INF folder

查看:30
本文介绍了来自 WEB-INF 文件夹的 web.xml 欢迎文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试从 WEB-INF 文件夹加载欢迎文件时收到 resquested 资源不可用错误,在我的 web.xml 中它看起来像这样:

I get the resquested resource is not available error while trying to load a welcome file from the WEB-INF folder, in my web.xml it looks like this:

<welcome-file-list>
    <welcome-file>WEB-INF/html/index.html</welcome-file>
</welcome-file-list>

换句话说,html文件位于名为html"的文件夹中的WEB-INF目录下...

In other words, the html files are located in the WEB-INF directory in the folder named "html"...

那么我该如何正确地做到这一点呢?所有这些路径都如此复杂,我的意思是有某种路径指南或其他什么东西吗?因为我无法开发,因为当找不到某些东西时,我会陷入这些事情中,因为我编写的路径的解释与我预期的不同......

So how do I do this correctly? It's so complex all this paths thing, I mean is there some kind of paths guide or anything? Because I just can't develop because I get stuck at these things when something can't be found because the path i write is interpreted differently than I expect it to...

推荐答案

不能直接访问 WEB-INF 文件夹下的文件.容器会在 WEB-INF/classes 中寻找类,WEB-INF 下的 jsp 文件可以被其他 JSP 包含,但是任何浏览器请求那里的资源都会得到 404 响应.

You cannot access files under WEB-INF folder directly. Container will look for classes in WEB-INF/classes and jsp files under WEB-INF can be included by other JSP, but any browser requesting resources down there will get a 404 response.

关于您在下面的疑问,如果您有一个标准的 Java EE webapp,则在您应该拥有的根文件夹下方:

About your doubt below, if you have a standard Java EE webapp, below the root folder you should have:

/-
 |
 |-META-INF/
 |-WEB-INF/
 |-custom1/
 |-custom2/

前两个是强制性的,但您可以创建额外的子文件夹(例如 customX).我个人创建了一个自定义文件夹资源"来分配 html、css 和 js 文件(在单独的子文件夹中).如果我有不应该直接访问的特殊 JSP 文件(仅通过包含),我会将它们放在 WEB-INF/中.

The first two are mandatory, but you can create extra subfolders (e.g. customX). Personally I create a custom folder "resources" to allocate there html, css and js files (in separate subfolders). If I have special JSP files which should not be accesed directly (only thru includes), I place them inside WEB-INF/.

这篇关于来自 WEB-INF 文件夹的 web.xml 欢迎文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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