首页 > 解决方案 > Url Problem while Developing on Localhost and deploy on Remote Virtual Server

问题描述

I have developed an WebApplication which runs on a Tomcat on my Notebook on Localhost. Now i have the task to deploy the Application to a remote Virtual Server. I coded all the redirects via JSF and a custom Servlet Class.For Example you press a Button and a Method gets called which redirects you to http://localhost:8080/myApp/some.xhtml. But when i Deploy the App to the remote Server i have to change all the redirects because it has now a different URL. Is there a way of mapping these URLS to their counterpart on the remote Server, so i don't have to change every single redirect in the xhtml Files and the Servlet? How is the way to go here?

标签: javatomcaturlxhtmlremote-server

解决方案


建议1。

不是重定向到http://localhost:8080/myApp/some.xhtml,而是从基本 URL(例如“ http://localhost:8080/myApp/ ”)和路径构建 URL。然后将基本 URL 设为配置参数。

另请参阅:servlet 的根 URl

建议2。

重定向到“/myApp/some.xhtml”并让 URI 解析器处理它。假设 URI 在原始 URL 的上下文中被解析,它应该去到正确的地方。


推荐阅读