我使用Spring创建了一个简单的Controller,它扩展了AbstractController。 它只是发出一个创建一个简单表单的视图,并返回actionURL 这样我的控制器中的handleActionRequest方法就会被调用 我看到Fiddler在回复中返回的值 但永远不会达到handleActionRequest方法。完全难倒。请帮忙!!!
这是portlet.xml的相关部分
<portlet id="Source">
<description>Source</description>
<portlet-name>source</portlet-name>
<display-name>source</display-name>
<portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
<init-param>
<name>contextConfigLocation</name>
<value>/WEB-INF/source-portlet.xml</value>
</init-param>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
<title>Source</title>
<short-title>Source</short-title>
<keywords>source ibi</keywords>
</portlet-info>
<portlet-preferences>
</portlet-preferences>
</portlet>
这是xml文件引用的ViewModeController:
package com.ibi.bip.portlet;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import org.springframework.web.portlet.ModelAndView;
import org.springframework.web.portlet.mvc.AbstractController;
import com.ibi.bip.portlet.ContactEvent;
public class ViewModeController extends AbstractController{
@Override
public void handleActionRequest(ActionRequest request,
ActionResponse response) throws Exception {
System.out.println("Entering ViewModeController.handleActionRequest");
String fName = request.getParameter("fName");
String lName = request.getParameter("lName");
String email = request.getParameter("email");
ContactEvent contact = new ContactEvent(fName, lName, email);
response.setEvent("hello", contact);
request.getPortletSession().setAttribute("contact", contact);
System.out.println("Exiting ViewModeController.handleActionRequest");
}
@Override
public ModelAndView handleRenderRequest(RenderRequest request,
RenderResponse response) throws Exception {
System.out.println("Entering ViewModeController.handleRenderRequest");
response.setContentType("text/html");
ModelAndView modelAndView = new ModelAndView("source");
if (request.getPortletSession().getAttribute("contact") != null) {
modelAndView.addObject("contact", request.getPortletSession()
.getAttribute("contact"));
}
System.out.println("Exiting ViewModeController.handleRenderRequest");
return modelAndView;
}
在Jetspeed中运行时,handleRenderRequest从source.jsp成功创建一个表单html,它在响应中返回值
这在Fiddler中显示为
[protocol] [host:port] / jetspeed / portlet / ns:Ym9wczguMDo6c291cmNlfGQxfGY /
但是从不调用ViewModeController(上面)中的handleActionRequest()。 :(