嗨,我开始lern liferay,有一个问题。我无法从jsp发送portlet在portlet中。
在jsp中我有:
<%@ 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>
:
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>");
}
}
我哪里可以搞错?我会在portlet的XML文件中写一些东西吗?
答案 0 :(得分:7)
这在很多层面都是错的 - 抱歉 - 我不知道从哪里开始:
<portlet:actionURL />
,而不是“HelloWorld
”processAction
而不是doGet
(听起来更像是一个servlet)HttpServletRequest
才能编写内容<html>
,<head>
,只是门户网站将嵌入页面的部分内容我建议从一些教程开始 - 比如Liferay in Action书籍 - 来获取基本概念。
答案 1 :(得分:2)
表单标记中的操作属性应为<portlet:actionURL />
<form action="<portlet:actionURL />" method="post" enctype="multipart/form-data">
同样在portlet java文件中实现POST的processAction(ActionRequest request, ActionResponse response)
方法。