Hi im begin lern liferay and have one problem. I cant send POST in portlet from jsp.
In jsp i have :
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<portlet:defineObjects />
<div>
<form action="HelloWorld" method="post" enctype="multipart/form-data">
<div id="up">
<input id="fileUpload1" type="button" name="filename" value="Привет">
</div>
</form>
</div>
in portlet:
public class HelloWorld extends GenericPortlet {
protected void doGet(ActionRequest request,
ActionResponse response) throws ServletException, IOException
{
// reading the user input
//String color= request.getParameter("color");
HttpServletResponse servletResponse = PortalUtil.getHttpServletResponse(response);
PrintWriter out = servletResponse.getWriter();
out.println("<HTML>");
out.println("<HEAD <TITLE> Upload4 </TITLE> </HEAD>");
out.println("<BODY>");
out.println("<FORM action = \"HelloWorld\" method = \"post\" enctype = \"multipart/form-data\">");
out.println("<div id='up'>");
out.println("Hello World!!");
out.println("<input id='fileUpload1' type='button' name='filename' value='Привет'>");
out.println("</div>");
out.println("</FORM>");
out.println("</BODY>");
out.println("</HTML>");
}
}
Where i can mistake? I gonna write something in portlet's XML files?
This is wrong on so many levels - sorry - that I don't know where to start:
<portlet:actionURL />
, not to " HelloWorld
" processAction
instead of doGet
(which sounds rather like a servlet) HttpServletRequest
in your action handler in order to write content <html>
, <head>
, but just some part that the portal will embed on a page I recommend to start with some tutorial - like the Liferay in Action book - to get the basic concepts.
Action attribute in form tag should be <portlet:actionURL />
<form action="<portlet:actionURL />" method="post" enctype="multipart/form-data">
Also in portlet java file implement processAction(ActionRequest request, ActionResponse response)
method for POST.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.