我在Liferay平臺中開發了一個portlet,其中我添加了從URL獲取查詢參數值的邏輯。我有這個網站:http://localhost:8080/web/guest/example,現在這個網站正在被另一個不在Liferay中的外部網站調用,查詢參數結束於:http://localhost:8080/web/guest/example?value=test。在Liferay Portlet代碼中,我應用了邏輯從URL中獲取不起作用的參數值。它返回「空」值:從URL獲取參數值不起作用
HttpServletRequest httpReq = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(request));
String myValue = httpReq.getParameter("value");
System.out.println(myValue);
我想這種方式太多,但得到的查詢參數相同的「空」值:
HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(request);
String myValue = httpRequest.getParameter("value");
System.out.println(myValue);
任何建議什麼,我做錯了什麼或怎麼能我得到來自外部網站的查詢參數值?
您是否嘗試使用'request.getQueryString()'獲取它? –
我認爲你可能錯過了liferay-portlet.xml文件中的 false requires-namespaced-parameters> –
Gautam