简体   繁体   English

如何将Angle 6和Spring MVC与单个服务器集成?

[英]How do I integrate angular 6 and spring MVC with single server?

Angular 6 dist file is imported into the webapp folder.In the dispatcher servlet mapping the url pattern / is working for the REST api calls and the url pattern /** is used for index.html files. 将Angular 6 dist文件导入到webapp文件夹中。在调度程序servlet映射中,URL模式/用于REST api调用,URL模式/ **用于index.html文件。 What url pattern is to be used for accessing both angular 6 & REST apis. 什么URL模式将用于访问Angular 6和REST API。

Thanks 谢谢

Generally your root path so / should serve the static content and then you have a path like /api/* reserved for rest services. 通常,您的根路径so /应该为静态内容提供服务,然后您会保留/api/*类的路径供其余服务使用。 You can do this by putting server.contextPath=/api/* in application.properties or server.servlet.context-path if you are using spring boot 2.0.0. 如果您使用的是Spring Boot 2.0.0,则可以通过将server.contextPath=/api/*放在application.propertiesserver.servlet.context-path中来实现。 And the you just put all the static content in one of the folders: 然后,您只需将所有静态内容放入其中一个文件夹中:

  • /META-INF/resources/ / META-INF /资源/
  • /resources/ /资源/
  • /static/ /静态的/
  • /public/ /上市/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM