vue项目整合到springboot方法

其实方法很简单的,比直接放到tomacat时需要改动assetsPublicPath还简单。。。

直接打包,把dist目录下内容全部拷贝到springboot工程目录下的main\resources\static目录下

我这里是thymeleaf,使用的是templates下的模板

@Controller
public class pageController {
    @RequestMapping("/")
    public String index() {
        return "index";
    }
}

跳转到了templates下的index.html

所以我们在该index.html下用代码跳转到static下的index.html

<!DOCTYPE html>
<html>
<script>
   location.href = "index.html"
</script>
<body>
</body>
</html>

行了,启动springboot项目,然后浏览器输入:http://127.0.0.1:8080/

自动跳转为:http://127.0.0.1:8080/index.html#/

效果就出来了

发布了42 篇原创文章 · 获赞 7 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/jiyanglin/article/details/94990826
今日推荐