1. How to display a directory list:
When we test programs locally, we are generally used to traversing what files are in a certain directory in the browser. This requires the web server to support directory lists:
Open the file conf/web.xml and find the following code:
<param-name>listings</param-name>
<param-value>false</param-value>
Change false to true
2. Configure error-page: (Specify the page to handle errors)
Open the file D:demoWEB-INFweb.xml:
<error-page>
between <web-app>…</web-app>
<error-code>404</error-code>
<location>/NotFound.jsp</location>
</error-page>
(Errors with error code 404 are directed to NotFound.jsp)
<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page>
(When a 500 error occurs in the system, that is, an internal server error, jump to the error processing page error.jsp)
<error-page>
<exception-type>java.lang.NullException</exception-type>
<location>/error.jsp</location>
</error-page>
(When a java.lang.NullException (i.e. null pointer exception) occurs in the system, jump to the error handling page error.jsp)
……
remind:
The above pages need to be larger (>=2kB), otherwise they will not work.
Reason: Tomcat limits the bytes of such pages to no less than a certain number of bytes.
3. How to solve the problem of garbled characters in jsp page?
Add to the header of the page:
<%@ page contentType="text/html; charset=gb2312″%>