vue项目部署到ubuntu的Tomcat上时出现刷新404解决

打包后部署到Tomcat上可以运行 点击也没有问题就是一刷新就报404

这是因为 History模式出现的问题 具体解决方案 https://router.vuejs.org/zh/guide/essentials/history-mode.html 这是vue官方给出的解释,但是进去后发现没有Tomcat的解决方案。

解决方案:

在打包好的vue项目中新进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>

这样就解决了我的问题 

原解决方案链接:http://www.ngui.cc/vuejs/show-3346.html

 

posted @ 2019-07-19 14:37  辰辰的小屋  阅读(397)  评论(0)    收藏  举报