2 回答

TA貢獻(xiàn)1863條經(jīng)驗(yàn) 獲得超2個(gè)贊
這真的很痛苦。桌面.瀏覽不適用于錨點(diǎn),如這里所討論的:如何從Java啟動(dòng)帶有錨點(diǎn)的文件協(xié)議URL?該鏈接提供了窗口的可能解決方法。
使用Linux,您可以通過(guò)執(zhí)行以下命令來(lái)打開(kāi)網(wǎng)址:
Runtime.exec("open file:/D:/app/wildfly-13.0.0.Final/standalone/tmp/vfs/deployment/deployment545477ea955f6f3d/mainUI-1.2.14.0.war-7f1f239336b4e258/documentation/index.htm#_Toc502051959");

TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超2個(gè)贊
解決我的問(wèn)題,如果突然有人遇到同樣的問(wèn)題:
String menuNameNotBlanked = menuName == null ? "" : menuName.replace(" ","_");
String formPathNotBlanked = formPath == null ? "" : formPath.replace(".xhtml","").replace("/","_");
String helpPath = ((ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext()).getRealPath(HELP_FILE_PATH);
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
URL contextURL = new URL(request.getScheme(),request.getServerName(),request.getServerPort(),request.getContextPath());
URL helpURL = new URL(contextURL.toString()+ "/" + HELP_FILE_PATH + AddLeadString(menuNameNotBlanked+formPathNotBlanked,"#"));
RequestContext.getCurrentInstance().execute("window.open('" + helpURL + "')");
添加回答
舉報(bào)