问题
I want to create some links in Oracle APEX to the application itself. But it changes in my development envireonment and the production environment. I need a way to determine my current hostname and port. Which function can help me?
回答1:
The necessary method is in the APEX_UTIL
-package and called HOST_URL. With the parameter, you can extend the output:
Given your hostname is example.com
and your port is 5883
.
function call | result
---------------------------------|-----------------------------------
APEX_UTIL.HOST_URL() | http://example.com:5883
APEX_UTIL.HOST_URL('SCRIPT') | http://example.com:5883/pls/apex/
APEX_UTIL.HOST_URL('IMGPRE') | http://example.com:5883/i/
The result with the value IMGPRE
depends on your configuration at Application Properties > User Interface > General Properties > Image prefix.
回答2:
I would try to avoid generating absolute URLs like http://domain/apex/f?p=123 to the same application or other applications on the same system. Use relative URLs instead to avoid changing domain names. For example just use
f?p=&APP_ID.:5:&SESSION.
if you want to reference a specific page within your application. But where possible you should use declarative links which automatically generate what's necessary. If you want to reference another app use
f?p=123
来源:https://stackoverflow.com/questions/30118926/how-to-determine-the-hostname-in-oracle-apex