Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Portlet块jsp页面_Java_Portlet - Fatal编程技术网

Java Portlet块jsp页面

Java Portlet块jsp页面,java,portlet,Java,Portlet,我对portlet有一个问题。当我在portlet.xmlstandart行中编写时 <portlet-class>com.liferay.util.bridges.mvc.MVCPortlet</portlet-class> 为什么是七开 这个问题得到了特别解决。 1.需要使用mvcportlet而不是genericportlet 2.从portlet中删除doView() 就这些。但还有其他问题。 1. MVCPortlet不是最佳选择。 2.如何在没有doView

我对portlet有一个问题。当我在
portlet.xml
standart行中编写时

<portlet-class>com.liferay.util.bridges.mvc.MVCPortlet</portlet-class>

为什么是七开

这个问题得到了特别解决。
1.需要使用
mvcportlet
而不是
genericportlet

2.从portlet中删除
doView()

就这些。但还有其他问题。
1. <代码>MVCPortlet不是最佳选择。

2.如何在没有
doView()
的情况下将参数从portlet发送到
view.jsp

是否进入
doView
?顺便说一句:将
error
作为实例变量将无法正常工作-您的portlet必须是线程安全的…我的英语很差。如果我理解正确,你会说这个portlet中的任何内容都不会影响jsp页面?NP。我只是想知道是否执行了
doView
。添加类似于日志语句的内容。。。
<portlet-class>test.uploadport</portlet-class>
package test;

import java.io.*;
import java.util.Iterator;
import java.util.List;

import javax.portlet.*;


import org.apache.commons.fileupload.*;
import org.apache.commons.fileupload.disk.*;
import org.apache.commons.fileupload.portlet.*;
import org.apache.commons.fileupload.servlet.*;
import org.apache.commons.fileupload.util.*;
public class uploadport extends GenericPortlet {
private String error;
public void doView(RenderRequest req, RenderResponse res)
throws IOException, PortletException
{
 WindowState state = req.getWindowState();
 res.setContentType("text/html");
 PortletSession session = req.getPortletSession(true);
 PortletContext context = getPortletContext();
 PortletRequestDispatcher rd;
 rd = context.getRequestDispatcher("/view.jsp");
 rd.include(req, res);

}
public void processAction(ActionRequest req, ActionResponse res)
throws IOException, PortletException
{
System.out.println("VASAY - PIROZJOK");
    PortletSession session = req.getPortletSession(true);
    DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory();
    PortletFileUpload portletFileUpload = new PortletFileUpload(diskFileItemFactory);
    List<FileItem> list=null;
    String mifpath= "1";
    String path = " ";
    String mif = " ";
    String from = "\\\\";
    String to ="/";
    String error="";
    try{
        list = portletFileUpload.parseRequest(req);
        Iterator<FileItem> it = list.iterator();
        //response.setContentType("text/html");
       while ( it.hasNext() ) 
       {

          FileItem item = (FileItem) it.next();
          File disk = new File("C:/uploaded_files/"+item.getName());

    path = disk.toString();

    String code = new String(path.substring(path.lastIndexOf("."), path.length()).getBytes("ISO-8859-1"),"utf-8");
    if (code.equalsIgnoreCase(".zip"))
    {
        System.out.println("PIROZJOK");
        mifpath=path;
        mif = mifpath.replaceAll(from, to);
        item.write(disk);
        error=unzip.unpack(mif, "C:/uploaded_files");
    }
    else
    {
        error = "Выбранный файл не является архивом zip";

    }
  }
}
 catch ( Exception e ) {
 log( "Upload Error" , e);
} 

}
 private void log(String string, Exception e)
   {
// TODO Auto-generated method stub

}
}