Angular Spring启动应用程序:请求失败,状态为404

时间:2020-04-17 15:39:12

标签: angular spring-boot tomcat

我正在尝试在Centos 7上部署现有的war(Angular + Spring boot)应用程序,但是我收到了这些消息:

enter image description here enter image description here 我试图在tomcat中启用CORS,但仍然收到相同的错误。 另外,我还收到此消息“源映射错误:请求失败,状态为404”,这两种技术对我来说都是新手,但我认为这与声明js文件有关,还是其他原因?

enter image description here

1 个答案:

答案 0 :(得分:0)

尝试在cors.allowed.origins的CORS过滤器中添加tomcat/conf/web.xml

<filter>
  <filter-name>CORS</filter-name>
  <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
  <init-param>
    <param-name>cors.allowed.origins</param-name>
    <param-value>*</param-value>
  </init-param>
  <init-param>
    <param-name>cors.allowed.methods</param-name>
    <param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
  </init-param>
  <init-param>
    <param-name>cors.allowed.headers</param-name>
    <param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
  </init-param>
</filter>
<filter-mapping>
  <filter-name>CORS</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>
相关问题