天天看点

linux:vue在tomcat的部署

1.webpack打包时修改:

config/index.js 配置assetsPublicPath:'./' (也可以加项目名称)

对于css里面的图片,webpack会打包读取不到:打开build / utils.js:加入publicPath:'../ ../'

linux:vue在tomcat的部署

2.在路由里面加入:mode:'history'和base:'mynote'

linux:vue在tomcat的部署

3.针对history模式路由刷新页面404问题:创建一个WEB-INF/web.xml文件:

linux:vue在tomcat的部署

web.xml:

<?xml version="1.0" encoding="UTF-8"?>

<web-app metadata-complete="true" version="3.1" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee">

<display-name>Router for Tomcat</display-name>

<error-page>

<error-code>404</error-code>

<location>/index.html</location>

</error-page>

</web-app>