Create demo.jsp in the portal directory. We can add this jsp by JSP Hook in docroot/META-INF/custom_jsps/html/portal directory:
<h3>Welcome! you are redirected here from Custom Struts Action class CustomAction</h3>
Now create CustomAction class for Struts action as below. CustomAction class extends BaseStrutsAction but not BaseStrutsPortletAction. By this way we add action class in portal level.
package com.evon.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.liferay.portal.kernel.struts.BaseStrutsAction;
public class CustomAction extends BaseStrutsAction{
@Override
public String execute(HttpServletRequest request,
HttpServletResponse response) throws Exception {
return "/portal/demo.jsp";
}
}
If you want to make struts action path to be public then create portal.properties in docroot/WEB-INF/src and write the below line in portal.properties
auth.public.paths=/portal/createActionExample
Deploy the Hook and access the http://localhost:8080/c/portal/createActionExample URL. It will display demo.jsp page and you will see the message that we have defined in that jsp.
0 Comment(s)