问题1:web前端部署在tomcat下,登录进入后刷新页面出现404
解决办法:项目下创建WEB-INF/web.xml。
web.xml内容
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0"
metadata-complete="true">
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
<error-page>
<error-code>404</error-code>
<location>/index.html</location>
</error-page>
</web-app>
问题2: 部署在Nginx下,指令页面访问404
解决办法:编辑Nginx配置文件,nginx/conf/nginx.conf,加入红色加粗部分。
重启服务,进入nginx/sbin目录下,执行 ./nginx -s reload
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}