vue項目部署刷新404問題


1、部署在tomcat下:

      找到tomcat下的webapps文件下

      WEB-INF文件夾

      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_3_1.xsd"
version="3.1" metadata-complete="true">
<display-name>Router for Tomcat</display-name>
<error-page>
<error-code>404</error-code>
<location>/index.html</location>
</error-page>
</web-app>

沒有此文件的話、直接創建即可

 

2、nginx下

      找到nginx的配置,添加一個404的處理

     

    location / {
        index index.html index.htm;
        proxy_set_header Host $host:$server_port;
        error_page  404  /index.html;
    }

 

 

 

最后重啟即可  ,兩個服務端解決方法都是自己使用過的,不能解決的話,可能是前端的配置也有問題

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM