留言板
liferay 6.x: Query String params not readable from request in JSP
Darshan Maharana,修改在12 年前。
liferay 6.x: Query String params not readable from request in JSP
Junior Member 帖子: 65 加入日期: 07-5-29 最近的帖子
Hi All,
Following example would work fine in Liferay 4.4.x:
- Lets say you have a portlet with id 'myportlet'.
- You have added this portlet to a page "page1" and it is accessible at http://localhost:8080/web/guest/page1
- You type url http://localhost:8080/web/guest/page1/_myportlet_mode=test1 in the browser address bar
- A JSP in myportlet tries to read 'mode' by following code:
String modeString = ParamUtil.getString(request, "mode", "ERROR");
- After this statement is executed in JSP, if you check value of modeString, it would be "test1".
This example fails in Liferay 6 (tested with ver 6.05). The value of modeString in Liferay 6 is "ERROR" which is a default value passed to ParamUtil.getString()
What has changed ? How to read query string params in Liferay 6?
thanks,
-darshan
Following example would work fine in Liferay 4.4.x:
- Lets say you have a portlet with id 'myportlet'.
- You have added this portlet to a page "page1" and it is accessible at http://localhost:8080/web/guest/page1
- You type url http://localhost:8080/web/guest/page1/_myportlet_mode=test1 in the browser address bar
- A JSP in myportlet tries to read 'mode' by following code:
String modeString = ParamUtil.getString(request, "mode", "ERROR");
- After this statement is executed in JSP, if you check value of modeString, it would be "test1".
This example fails in Liferay 6 (tested with ver 6.05). The value of modeString in Liferay 6 is "ERROR" which is a default value passed to ParamUtil.getString()
What has changed ? How to read query string params in Liferay 6?
thanks,
-darshan
Hajri Mohamed,修改在12 年前。
RE: liferay 6.x: Query String params not readable from request in JSP
Junior Member 帖子: 71 加入日期: 11-3-2 最近的帖子
i havent a big idea about this, but i m just trying to help you to find a possible solution, i m using liferay 6, surely many things were changed from 4, instead of _myportlet_mode try to use p_p_mode=view
regards
regards
Darshan Maharana,修改在12 年前。
RE: liferay 6.x: Query String params not readable from request in JSP
Junior Member 帖子: 65 加入日期: 07-5-29 最近的帖子
Found the answer !
Further testing on this shows, both of following URL options work in Liferay 6:
http://localhost:8080/web/guest/page1?p_p_id=myportlet&_myportlet_mode=test1
http://localhost:8080/web/guest/page1?p_p_id=myportlet&mode=test1
So you need to add p_p_id=<portlet-id> to the URL so that query string params
get populated correctly in 'request' in JSP .
thanks,
-darshan
Further testing on this shows, both of following URL options work in Liferay 6:
http://localhost:8080/web/guest/page1?p_p_id=myportlet&_myportlet_mode=test1
http://localhost:8080/web/guest/page1?p_p_id=myportlet&mode=test1
So you need to add p_p_id=<portlet-id> to the URL so that query string params
get populated correctly in 'request' in JSP .
thanks,
-darshan