问题
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>
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...
回答1:
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.
EDIT: 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/
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/.
回答2:
Files in the WEB-INF directory are not directly available for access.
See URL:
Place private files in the WEB-INF directory, under the root directory. All files under WEB-INF are private, and are not served to a client.
回答3:
WEB-INF folder is not accessible directly to web browser since this folder is meant for keeping files which are internal to application i.e. classes and configuration files etc. welcome page is something that should not contain any specific or private information, so can be kept in parallel to WEB-INF folder. All static html files can be placed at same hierarchy as of welcome file. To distinguish better, we can create sub folders.
回答4:
i'm gonna tell you how i have the wellcome file, i have it like this
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
and the "index" is in the "web" folder, maybe you should set the wellcome file with just the name.
I hope this one helps you ;)
来源:https://stackoverflow.com/questions/16180090/web-xml-welcome-file-from-web-inf-folder