简体   繁体   中英

How to identify form action URI from processAction() method in Portlet class?

I created a form like;

<portlet:actionURL var="myFriendlyURI">  
<portlet:param name="action" value="addUser"></portlet:param>  
</portlet:actionURL>  

<form id="userForm" name="userForm" action="${myFriendlyURI}" method="post">  

 Name :- <input type="text" name="userName">  

 <input type="submit">  
</form> 

In processAction(ActionRequest request, ActionResponse response) method, how can I identify the request URI based on myFriendlyURI?

request.getAttribute("javax.servlet.forward.request_uri").toString()) is giving only "/web/portal/Adduser-PageName".

I just want to check the request just like we are doing in Servlet class ;

if(request.getRequestURI().endsWith("user/add")) { // <form action="user/add" ..... >
    System.out.println("Ends with :  user/add ");
    // do actions here
 }

Use this

HttpServletRequest convertReq = PortalUtil.getHttpServletRequest(actionRequest);
HttpServletRequest originalReq = PortalUtil.getOriginalServletRequest(actionRequest);

PortalUtil.getCurrentCompleteURL();

Reference to the link has many examples

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM