修改项目默认路径,修改默认项目 http://xxx.xxxxxx.xxx 直接访问
找到tomcat路径中conf文件夹下server.xml文件找到
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
修改成
<Host name="localhost" appBase="/xxx/xxx/xxx/xxx/webapps"
unpackWARs="true" autoDeploy="true">
<Context docBase="/xxx/xxx/xxx/wxs_home" path="" debug="0" reloadable="true" crossContext="true"/>
说明:/xxx/xxx/xxx/xxx/webapps修改的项目默认路径 /xxx/xxx/xxx/wxs_home 修改的默认项目,放入自定义的首页index.jsp/index.html ;顺便放入错误提示页面error.jsp
错误提示页面:
error.jsp
-
<%@ page language="java" contentType="text/html; charset=UTF-8"
-
pageEncoding=
"UTF-8"%>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
<html>
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-
<title>xxx错误
</title>
-
</head>
-
<body>
-
哎哟喂!您乘坐的这条“程序”违反了tomcat规则!请稍后访问......
-
</body>
-
</html>
找到tomcat路径中conf文件夹下web.xml文件找到
找到这段
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
在下面添加
-
<!-- 400错误 -->
-
<error-page>
-
<error-code>400
</error-code>
-
<location>/error.jsp
</location>
-
</error-page>
-
<!-- 404 页面不存在错误 -->
-
<error-page>
-
<error-code>404
</error-code>
-
<location>/error.jsp
</location>
-
</error-page>
-
<!-- 500 服务器内部错误 -->
-
<error-page>
-
<error-code>500
</error-code>
-
<location>/error.jsp
</location>
-
</error-page>
-
<!-- java.lang.Exception异常错误,依据这个标记可定义多个类似错误提示 -->
-
<error-page>
-
<exception-type>java.lang.Exception
</exception-type>
-
<location>/error.jsp
</location>
-
</error-page>
-
<!-- java.lang.NullPointerException异常错误,依据这个标记可定义多个类似错误提示 -->
-
<error-page>
-
<exception-type>java.lang.NullPointerException
</exception-type>
-
<location>/error.jsp
</location>
-
</error-page>
-
-
<error-page>
-
<exception-type>javax.servlet.ServletException
</exception-type>
-
<location>/error.jsp
</location>
-
</error-page>
重启tomcat服务器,默认项目http://xxx.xxxxxx.xxx; 400/404/500类型的错误页面:http://xxx.xxxxxx.xxx/error.jsp
转载:https://blog.csdn.net/tsxw001/article/details/112131155
查看评论