简体   繁体   English

聚合物意外的路由结果主页

[英]Polymer unexpected routing result home page

I cloned polymer starter kit 1.0 and its working perfectly fine only if the url is : localhost:8080 . 我克隆了聚合物入门工具包1.0,并且只有在url为: localhost:8080 ,它才能正常工作。 When I tried with Eclipse and Apache Tomcat 8.0 to build a Java MVC application then URL would be as : localhost:8080/project-name . 当我尝试使用Eclipse和Apache Tomcat 8.0构建Java MVC应用程序时,URL为: localhost:8080/project-name

Now the behaviour of the page navigation changed dramatically. 现在,页面导航的行为发生了巨大变化。 When I start the project the URL comes as: localhost:8080/project-name/#!/project-name 当我启动项目时,URL为: localhost:8080/project-name/#!/project-name

But it should come like: localhost:8080/project-name and should show home page and on clicking on users or contact tab the url should be : 但是它应该是这样的: localhost:8080/project-name ,应该显示主页,并且在单击用户或联系人选项卡时,URL应该是:

  • localhost:8080/project-name/#!/users
  • localhost:8080/project-name/#!/contact but it is showing like: localhost:8080/project-name/#!/contact但显示如下:
  • localhost:8080/project-name/#!/project-name/users
  • localhost:8080/project-name/#!/project-name/contact

I tried to make app.baseUrl =" "; 我试图使app.baseUrl =" "; . Changed the routing.html routing for home to empty or '*'but nothing worked. 将home的routing.html路由更改为或“ *”,但没有任何效果。 Any help would be highly appreciated. 任何帮助将不胜感激。

Thanks. 谢谢。

You must deploy your app as "ROOT.war" to hide the projects context. 您必须将应用程序部署为“ ROOT.war”以隐藏项目上下文。 The name of your project is deployed as the "context" in the URL. 项目名称在URL中作为“上下文”部署。

Naming your app ROOT simply tells Tomcat it is the main app to run and you will indeed get below as your projects context. 为您的应用程序命名ROOT只是告诉Tomcat它是要运行的主要应用程序,您确实会从项目上下文中了解到以下内容。

localhost:8080 本地主机:8080

Don't worry about the Tomcat homepage, I simply rename it to "ROOT-1" when I really want to keep it. 不用担心Tomcat主页,当我确实要保留它时,只需将其重命名为“ ROOT-1”。 Also don't worry about the context while running in eclipse because it would awkward to test your app as ROOT. 另外,在Eclipse中运行时也不必担心上下文,因为将您的应用程序测试为ROOT会很麻烦。 Just rename the .war to ROOT before launch. 只需在启动前将.war重命名为ROOT。

When you see the "#" it usually means your are navigating to some point in an html file, ie looks like your app is SPA. 当您看到“#”时,通常意味着您正在导航到html文件中的某个点,即,看起来您的应用程序是SPA。

"#!/appComponent" “#!/ appComponent”

The line below simply looks like you have a SPA style page with the same name as your project with all the other pages inside of it. 下面的行仅看起来像您拥有一个SPA样式页面,该页面与您的项目同名,并且其中的所有其他页面都在其中。

localhost:8080/project-name/#!/project-name/users 本地主机:8080 /项目名称/#!/项目名称/用户

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

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