Portlet页面:
package com.demo.ajax;
import java.io.IOException;
import java.io.PrintWriter;
import javax.portlet.PortletException;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import com.liferay.util.bridges.mvc.MVCPortlet;
/**
* Portlet implementation class AJAXPortlet1
*/
public class AJAXPortlet1 extends MVCPortlet {
//ajax请求时候只能使用portlet:resourceURL 进入serveResource方法中
@Override
public void serveResource(ResourceRequest resourceRequest,
ResourceResponse resourceResponse) throws IOException,
PortletException {
String resourceId = resourceRequest.getResourceID();
PrintWriter writer = resourceResponse.getWriter();
if("wq1".equals(resourceId)){
writer.print("jquery请求!");
}
if("wq2".equals(resourceId)){
writer.print("aui请求!");
}
writer.flush();
}
}</