Integrate struts 2 in Liferay portlet

Liferay is a Open Source Content Management System and it’s popularity increasing day by day  but there are no much tutorials on this. Sometimes we find some examples but it may not work exactly the way have been written in the websites. Sometimes the tutorial steps have not been started from the scratch and it results confusion. I am going to give an example here step by step on how to integrate struts2 with liferay portlet or plugin project. I have extracted it from the Original Tutorial.

There are two modes in the original post but I have only worked with “edit” mode. I also had many confusions when I first read the original post and it did not work for me so I decided to jot down here.
1. First create a Liferay Plugin Project. Go to File->New->Other. Select from wizard Liferay->Liferay Plugin Project.

Input the mandatory fields as shown below and click Next.
struts 2 integration example with liferay

2. Select Liferay MVC in the next screen as shown below. Click Finish.
struts 2 integration example with liferay

3. Now you will see skeleton for the project will be generated. Now download the corresponding jars and put under WEB-INF/lib directory as show below in the screen-shot.
struts 2 integration example with liferay

4. Modify the web.xml file as given below


5. modify portlet.xml as shown below


6. create a domain or model object


7. create action classes for performing CRUD operations



8. Create nested directories html/edit

9. create two jsp files index.jsp and edit.jsp under html/edit.





10. Create struts.xml file and put under src directory


11. If everything was fine now deploy the application. Simply drag Struts2-portlet and drop onto the server. You can also deploy the application – do right click on the Struts2-portlet and go to Liferay->SDK->deploy.

12. Now go to http://localhost:8080 and logged in to the Liferay Portal. Go to Add->More…. Under Sample look for Struts2 portlet and add it clicking on “Add” link right to the Struts2 portlet.

struts 2 integration example with liferay

13. Now you see the Struts2 portlet appears onto the body of the Liferay Portal. Now you can manage bookmarks.

Thanks your patience. Please do not forget to leave a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.