Это мой класс с аннотацией @ProcessAction.Когда я ввожу текстовое поле, в консоли будут отображаться входные данные:
public class FirstGenericDemo extends GenericPortlet {
public void init() {
viewTemplate = getInitParameter("view-template");
}
@RenderMode(name= "view")
public void myView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
include(viewTemplate, renderRequest, renderResponse);
}
//Annotation
@ProcessAction(name = "myActionMethod")
public void myActionMethod(ActionRequest request, ActionResponse response) throws PortletException, IOException {
// TODO Auto-generated method stub
String name = ParamUtil.getString(request,"name");
System.out.println("Name => " + name);
}
protected void include(String path, RenderRequest renderRequest,
RenderResponse renderResponse)
throws IOException, PortletException {
PortletRequestDispatcher portletRequestDispatcher =
getPortletContext().getRequestDispatcher(path);
if (portletRequestDispatcher == null) {
_log.error(path + " is not a valid include");
}
else {
portletRequestDispatcher.include(renderRequest, renderResponse);
}
}
protected String viewTemplate;
private static Log _log = LogFactoryUtil.getLog(FirstGenericDemo.class);
}
А вот myView.jsp:
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
This is the <b>First Generic Demo</b> portlet in View mode.
<portlet:actionURL var="myaction" name="myActionMethod">
</portlet:actionURL>
<form action="${myaction}" method="post">
Name: <input type = "text" name="name">
<input type="submit" value="SUBMIT">
</form>
Но когда язапустить его всегда печатает «Name => null» в консоли.Как я мог это исправить?