exception trace is printed here.Įrror pages like 500, 505, etc. exception can be handled here, such as logging, redirecting, and so on. Note that isErrorPage familiarity must be true to use the exception object. If it still does not display, check the IE setting to check that option.Įxception.printStackTrace(response.getWriter()) You can add some additional information to increase the page size to more than 512 bytes. right click on the server tomcat in eclipse click on properties click switch location a little server will appear on the left side in the navigation view double click on it after you have launched your server Then select use Tomcat installation and save this will solve that common 404 problem. Because IE only displays error pages larger than 512 bytes by default. Note that the error page must be greater than 512 bytes or IE will not be displayed. Request.attribute = /page_not_exists.html For example, suggest possible correct urls and so on.įor example: visit a page that does not exist page_ES92en_exist.html, and the information displayed is: You can also see which file was visited incorrectly and which error page was jumped to for more detailed and human error handling. Out.println("request.attribute = " + attribute) Īll the variables in request are printed in the code. Object attribute = request.getAttribute(attributeName) String attributeName = attributeNames.nextElement() attributeNames = request.getAttributeNames() Then place two files, 404.jsp and exception.jsp, under the errorpages referenced in this web. Note that the error page must begin with "/" so that any path 404 error page and exception error will map to both files. Can be configured by error type, error code. The Servlet specification declares the relevant API as defined in web.xml for each web application. If you want to customize the error page, you do not need to modify the class. This will automatically display the page you just specified when you visit a page that doesn't exist Just add 1 configuration to the web.xml of the project You want to be able to give a user friendly, realistic interface when there are 404, 500 errors on the server Now enter an address that does not exist and successfully jump to the custom error page. Then, I type in which does not exist, 404 still appears,īack to 1, our web.xml is under an application, it should be 404 for this application, and is accessing tomcat's own application, then the ES38en.xml configuration should be configured under webapp/Root.īelow the Root directory are the Tomcat apps, just replace them with your own. Now visit one of the pages under the project that does not exist, and you will go to the custom pagenotfound page, so that the ES23en-ES24en-ES25en configuration in struts can be removed, because the 404 is left to tomcat. After verification, the custom error page can be set in web.xml of the project, and the Settings are as follows: It is no longer the processing scope of struts, so this should be the processing scope of the application. The result is that the 404 error still occurs. This means that when I visit action, if I don't find action, I go to this page, but if I don't use.do or.action and use.jsp or.html to access the page,struts will not handle it. The starting point of the problem is that I define the error page in Struts2, which is defined as follows in Struts2: In order to get a good user experience, users should not be exposed to the 404 page.