Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/361.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.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打开一些文档_Java_Solr - Fatal编程技术网

使用java打开一些文档

使用java打开一些文档,java,solr,Java,Solr,我有一个index.jsp页面。在这个页面中,我用从Solr数据库中获取的一些记录动态地填充表。我的剧本是这样的 <script> if($.fn.dataTable.isDataTable( '#example' )){ var table = $('#example').DataTable(); } function getData(){ $('#example tbody').html(''); var URL_PREFIX="http://local

我有一个index.jsp页面。在这个页面中,我用从Solr数据库中获取的一些记录动态地填充表。我的剧本是这样的

<script>
if($.fn.dataTable.isDataTable( '#example' )){
    var table = $('#example').DataTable();
}
function getData(){

    $('#example tbody').html('');
    var URL_PREFIX="http://localhost:8983/solr/archiveCore/select?q=strSO_copy:";
    var URL_MIDDLE="AND PackName_copy:";
    var URL_SUFFIX="AND DocType_copy:";
    var strSO="\"" + $("#ngramBoxstrSO").val() + "\"";
    var PackName="\"" + $("#ngramBoxPackName").val() + "\"";
    var DocType="\"" + $("#ngramBoxDocType").val() +"\"";
    var URL=URL_PREFIX + strSO + URL_MIDDLE + PackName + URL_SUFFIX + DocType;
    $.ajax({
        url:URL,
        dataType:'jsonp',
        jsonp : 'json.wrf',
        type :'get',
        cache :false,
        success: function(data){
            var docs=data.response.docs;
            var html='';        
            $.each(docs,function(key,value){
                var arrayExtensions=["jpg","JPG","JPG File","jpeg","JPEG image","PNG","TIFF image","tiff"];
                html+='<tr>';
                html+='<td>'+value.id+'</td>';
                html+='<td>'+value.strSO+'</td>';
                html+='<td class="text-center">'+value.PackName+'</td>';
                html+='<td class="text-center">'+value.DocType+'</td>';
                html+='<td class="text-center">'+value.DocName+'</td>';
                html+='<td class="text-center"><form method="POST" action="openDocumentServlet" target="_blank"><input name="document" value="'+value.FilePath+'" hidden><input name="docName" value="'+value.FileName+'" hidden><input id="buton" type="submit"  class="btn btn-sm" value="OPEN"></form></td>';
                html+='<td class="text-center" onmouseover="mouseOver(this)" onmouseout="mouseOut(this)"><p><a href=""><img src="images//SoftwareIcons-21-512.png" width=50; height=50; name="'+value.FileName+'" id="'+value.FilePath+'" alt="'+arrayExtensions.indexOf(value.extType[0])+'"></a></p></td>';
                html+='</tr>';
            });

            $('#example').DataTable().destroy();
            $('#example tbody').html(html);
            var table=$('#example').DataTable({
                "aaSorting" : [],

            });
        },
    });


};
</script>
我的文档在服务器端。我将它复制到本地路径,如
T:/Temp/
,并在本地路径中打开文档。以前它有时运行正常,但现在它给了我这个错误

java.lang.NullPointerException
    org.solr.openDocumentServlet.doPost(openDocumentServlet.java:82)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

您的服务器是否有T驱动器?记住,它不会在本地机器上查找它。@Stultuske是的,它已经找到了。我找到了错误的原因。由于
BufferedInputStream
的原因,它给了我一个错误。我还在努力。
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        String Docpath=request.getParameter("document");
        String docname=request.getParameter("docName");
        File file=new File("T:/Temp/"+docname);
        Path filePath=Paths.get("T:/Temp/"+docname);
        response.setContentType(Files.probeContentType(filePath));
        response.setHeader("Content-Disposition", "inline;filename="+docname);
        BufferedInputStream bis = null;
        BufferedOutputStream bos = null;
        try {
            ServletOutputStream  outs =  response.getOutputStream ();

            File original=new File(Docpath);
            File destination=new File("T:/Temp/");
            FileUtils.copyFileToDirectory(original, destination);
            InputStream input=new FileInputStream(file);
            bis=new BufferedInputStream(input);
            bos=new BufferedOutputStream(outs);
            byte[] buf = new byte[2048];

            int bytesRead;
            while ((bytesRead = bis.read(buf)) > 0) {
                bos.write(buf, 0, bytesRead);
            }
        }catch(IOException e){
            e.printStackTrace();
        }finally {
            bis.close();
            bos.close();
        }

        doGet(request, response);
    }
java.lang.NullPointerException
    org.solr.openDocumentServlet.doPost(openDocumentServlet.java:82)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)