简体   繁体   English

使用Maven构建的jboss服务器中.war文件的角度路由问题

[英]Angular Routing Issue with .war file in jboss server using maven build

I am creating a .war file and deploying in jboss server which is getting deployed successful. 我正在创建一个.war文件,并在成功部署的jboss服务器中进行部署。 While I hit the url: http://localhost:8080/pickingorder It successfully redirect to index page but when I refresh the page or click to go to perform any other task the angular component doesn't loads. 当我点击url时: http:// localhost:8080 / pickingorder它成功重定向到索引页面,但是当我刷新页面或单击以执行任何其他任务时,不会加载角度组件。 In short angular routing is somehow not working. 简而言之,角度布线不起作用。 Any help appreciated thanks in advance. 任何帮助表示感谢。

Attaching my Project structure screenshot .. 附上我的项目结构截图..

在此处输入图片说明

web.xml web.xml中

<welcome-file-list>
            <welcome-file>/dist/client/index.html</welcome-file>
          </welcome-file-list>

jboss-web.xml: 的jboss-web.xml中:

<jboss-web>
        <context-root>pickingorder</context-root>
    </jboss-web>

app-routing.module.ts: APP-routing.module.ts:

@NgModule({
      imports:
        [
          RouterModule.forRoot(routes, {
            initialNavigation: 'enabled', useHash: true, onSameUrlNavigation: 'reload'
          })
        ],
      exports: [RouterModule]
    })
    export class AppRoutingModule { }

index.html 的index.html

<base href="/pickingorder/dist/client/">

pom.xml 的pom.xml

在此处输入图片说明

Hi Finally I found the solution after trying lot of possibilities. 您好最后,我尝试了很多可能性后找到了解决方案。 I replace "href" tag to "routerLink" as below. 我将“ href”标签替换为“ routerLink”,如下所示。 Jboss doesn't understands the routing of Angular therefore 'Href' fails But there an way to handle in Angular using routerLink And it worked. Jboss不了解Angular的路由,因此'Href'失败了,但是有一种方法可以使用routerLink在Angular中进行处理,并且有效。

app.component.html : Old Code app.component.html:旧代码

   <ul class="dropdown-menu">
      <li><a href="pickingcreate">Create</a></li>
      <li><a href="pickingsearch">Search</a></li>
    </ul> 

app.component.html : Replaced Code app.component.html:替换的代码

      <ul class="dropdown-menu">
          <li><a routerLink="pickingcreate">Create</a></li>
          <li><a routerLink="pickingsearch">Search</a></li>
        </ul> 

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

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