错误
The requested resource (xxx/xxx/invoke) is not available
原因是在web.xml文件少对应的映射配置
JSP对应的配置
<servlet>
<servlet-name>Welcome</servlet-name>
<servlet-class>com.liferay.portal.kernel.servlet.PortletServlet</servlet-class>
<init-param>
<param-name>portlet-class</param-name>
<param-value>com.liferay.util.bridges.jsp.JSPPortlet</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Welcome</servlet-name>
<url-pattern>/Welcome/*</url-pattern>
</servlet-mapping>
strust2对应的配置
<servlet>
<servlet-name>Welcome </servlet-name>
<servlet-class>com.liferay.portal.kernel.servlet.PortletServlet</servlet-class>
<init-param>
<param-name>portlet-class</param-name>
<param-value>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Welcome</servlet-name>
<url-pattern>/Welcome/*</url-pattern>
</servlet-mapping>
另外配置文件 liferay-portlet.xml,portlet.xml,liferay-display,web.xml之间的关系
portlet.xml
<portlet id='welcomeId'> <!--可以随便起一个ID-->
<description xml:lang='EN'>mesWelcome</description>
<portlet-name>Welcome</portlet-name> <!-- 这个Name 必须与liferay-display.xml当中的portlet 的id一致。另外liferay-portlet.xml的portlet-name最好也与此处的portlet-name一致,如果不一致在添加应用的弹出菜单显示紫色 .在web.xml的servlet-name也需要跟此处的名字相一致-->
<display-name xml:lang='EN'>mesWelcome</display-name>
<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</portlet-class>
<init-param>
<name>viewNamespace</name>
<value>/myproject/view</value>
</init-param>
<init-param>
<name>defaultViewAction</name>
<value>mesWelcome</value><!-- 由于是应用了struts2 ,对应的是struts.xml里面的某一变量 -->
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<supported-locale>en</supported-locale>
<resource-bundle></resource-bundle>
<portlet-info>
<title>In Portlet.xml Title</title>
<short-title>showTitleOnAddApplication</short-title> <!-- 此处的内容会在添加应用的的菜单显示及添加的porlet的标题显示-->
<keywords>struts2,portlet</keywords>
</portlet-info>
</portlet>
jsp的portlet.xml内容
<portlet>
<portlet-name>Welcome</portlet-name>
<display-name>Welcome</display-name>
<portlet-class>com.liferay.util.bridges.jsp.JSPPortlet</portlet-class>
<init-param>
<name>view-jsp</name>
<value>/view.jsp</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<portlet-info>
<title>WelcomeJsp</title>
<short-title>Welcome</short-title>
<keywords>Welcome</keywords>
</portlet-info>
</portlet>
liferay-display.xml
(strust2与Jsp一致)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 4.0.0//EN" "http://www.liferay.com/dtd/liferay-display_4_0_0.dtd">
<display>
<category name="MES Portal">
<portlet id="Welcome">WelcomeJsp</portlet>
</category>
</display>
(strust2与Jsp一致)
liferay-portlet.xml
(strust2与Jsp一致)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 4.4.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_4_4_0.dtd">
<liferay-portlet-app>
<portlet>
<portlet-name>Welcome</portlet-name>
<instanceable>true</instanceable>
</portlet>
<!-- Role -->
<role-mapper>
<role-name>administrator</role-name>
<role-link>Administrator</role-link>
</role-mapper>
<role-mapper>
<role-name>guest</role-name>
<role-link>Guest</role-link>
</role-mapper>
<role-mapper>
<role-name>power-user</role-name>
<role-link>Power User</role-link>
</role-mapper>
<role-mapper>
<role-name>user</role-name>
<role-link>User</role-link>
</role-mapper>
</liferay-portlet-app>