java - 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?
解决方案
建议1。
不是重定向到http://localhost:8080/myApp/some.xhtml
,而是从基本 URL(例如“ http://localhost:8080/myApp/ ”)和路径构建 URL。然后将基本 URL 设为配置参数。
另请参阅:servlet 的根 URl
建议2。
重定向到“/myApp/some.xhtml”并让 URI 解析器处理它。假设 URI 在原始 URL 的上下文中被解析,它应该去到正确的地方。
推荐阅读
- python - 如果列列表中的所有值都为零,则创建新列
- javascript - 我们如何在 reducer NgRx 中使用 @inject
- postgresql - Postgresql 逻辑副本可以拥有自己的数据库对象吗?
- .net - 为什么 .NET 性能如此出色?
- python - 使用 Python 在每行的第一个和第二个单词后插入逗号?
- python - Discord Bot 未激活
- reactjs - 反应 useState 错误,我做错了什么?
- python - 如何在python中加入地图的值?
- php - Laravel 将某个参数传递给所有视图中的所有路由
- scala - 无法运行加特林测试(jvm 问题)