Transferred from: http://dejazhan.iteye.com/blog/1708785
Web-inf directory is not open to the outside, there is no way to directly access (that is, cannot be accessed through a URL). All can be accessed only through mappings, such as mapping to an action or a servlet accessing a specific page through a server-side jump. This can limit access and improve security.
1, the page resource files can only be placed under the Webroot, such as Css,js,image and so on. It can't be quoted under Web-inf.
2, can only use the steering way to access the JSP in the Web-inf directory, do not have to redirect the way to request any resources in the directory.
REDIRECT mode: Configure <forward Name= "Success" Path= "/web-inf/main.jsp" redirect= "true"/> as in the Struts-config file
or Response.sendredirect ("/error.jsp") in action;
The meaning of redirection is that the server sends the address to the client and allows the client to access it. This approach clearly targets the Web-inf directory as useless.
3, Web-inf directory when the file access resource files, you can ignore Web-inf this layer of directory. If you want to use a CSS file in the CSS directory, index.jsp. <link rel= "stylesheet" type= "Text/css" href= " css/**.css"/> That's it, okay? From the client's address you can see that the server steering index.jsp is under Webroot. So index.jsp and CSS directories can be said to be the same level directory.
4, how to access the files in the Web-inf directory.
(1) Mode one:
Used in main.jsp
<a href= "oa.do " > Test the path of OA </a>
Or
<jsp:forward page = "/web-inf/jsp/test/test.jsp"/>
Access.
(2) mode two: in the action class or in the Struts.xml
If main.jsp has a lot of links to other pages in the Web-inf directory. Then there must be 10 steering action. This can be done with the Dispatchaction class plus parameters specifically for steering.
1 request.getrequestdispatcher ("/web-inf/main.jsp"). Forward (request, response);
Configuring in the Struts-config file
<name= "Success" path= "/web-inf/main.jsp"/>
This is where the server reads the contents of the page and sends it to the client. The address of the client is unchanged. Content Jumps
Considerations for JSP placed under Web-inf