R语言中利用download.file时出现错误,求大神帮助!!!

url <- "http://drygin.ccbr.utoronto.ca/~costanzo2009/sgadata_costanzo2009_rawdata_101120.txt.gz"
download.file(url, file.path("Data", "sgadata_costanzo2009_rawdata_101120.txt.gz"), method="curl

上面是程序运行后出现错误
Error in download.file(url, file.path("Data", "sgadata_costanzo2009_rawdata_101120.txt.gz"), :
'curl' call had nonzero exit status
In addition: Warning message:
running command 'curl "http://drygin.ccbr.utoronto.ca/~costanzo2009/sgadata_costanzo2009_rawdata_101120.txt.gz" -o "Data/sgadata_costanzo2009_rawdata_101120.txt.gz"' had status 127
这到底是怎么回事啊
求大神帮助

1个回答

文件太大了吧,有100多兆。所以出错了。

qq_38809850
天天向上的Q宝宝 100多M就不行了啊,好无语啊,谢谢!
2 年多之前 回复
cjws555
cjws555 是嘛233333
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
R语言安装包总是报错,本地安装也不行。总是提示安装有非0出口
小白一枚,安装bioconductor里面的"org.Hs.eg.db"包,总是不成功。。 ![图片说明](https://img-ask.csdn.net/upload/202002/14/1581651842_314166.jpg) Warning messages: 1: In download.file(url, destfile, method, mode = "wb", ...) : downloaded length 48910336 != reported length 81813830 2: In install.packages(...) : installation of package ‘org.Hs.eg.db’ had non-zero exit status 有没有大神帮忙解答下
Rstudio: Error in file(file, "rt") : 无法打开链结
* 尝试在网上下载excel然后打开,下载成功了,但是却无法打开文件 ``` > download.file(fileurl,destfile = "pmi data.xlsx") 试开URL’http://data.eastmoney.com/cjsj/pmi.html' Content type 'text/html' length 144327 bytes (140 KB) downloaded 140 KB ``` * 在文件夹中也可以显示出下载文件的样式: ![图片说明](https://img-ask.csdn.net/upload/201911/24/1574598837_878772.png) * 但是再次打开的时候,却显示无法打开链接: ``` > read.table("fileurl") Error in file(file, "rt") : 无法打开链结 此外: Warning message: In file(file, "rt") : 无法打开文件'fileurl': No such file or directory > ``` **请教各位大神,为啥无法打开文件,万分感谢** 已经尝试过setwd,文件夹没有问题,是目录的文件夹 ``` > getwd() [1] "D:/coursera/coursera class examples" > list.files("D:/coursera/coursera class examples") [1] "300.csv" "data" [3] "pmi data.xlsx" ```
GDAL读取tif数值出现问题?急求大神指点!!!!!
文件是用arcgis软件分类后存储的tif文件,分了20个类,灰度值应该是1-20之间的整数值,在arcgis软件中显示是这样的正常值,但是用VS2010+GDAL中读取时会出现灰度值不是这个,总是32768或0啊什么的值。我程序读取网上下载的原始geotiff的高程数据是完全没问题的,分类后的数据怎么就读不出来了呢?我写了个大致代码如下,望大神给我分析一下,第一天注册CSDN,谢谢! #include "stdafx.h" #include "gdal_priv.h" #include <iostream> #include <iomanip> #pragma comment(lib, "gdal_i.lib") #include<fstream> #define TTYPE short //方便数据类型的修改 using namespace std; //using namespace System; int main(int argc, char* argv[]) { int num_iamge_size=0; ofstream myofstream("D:\\输出结果.txt") ; TTYPE *pafScanblock1; //开辟缓存区 char *file_path_name="D:\\TempForMapEMC\\iso20_min100.tif"; GDALDataset *poDataset; //GDAL数据集 GDALAllRegister(); //注册所有的驱动 poDataset = (GDALDataset *) GDALOpen(file_path_name, GA_ReadOnly ); if( poDataset == NULL ) { cout<<"fail in open files!!!"<<endl; return 0; } //获取图像波段 GDALRasterBand *poBand1; poBand1=poDataset->GetRasterBand(1); //获取图像的尺寸 int nImgSizeX=poDataset->GetRasterXSize(); //图像X尺寸 int nImgSizeY=poDataset->GetRasterYSize(); //图像Y尺寸 //获取坐标变换系数 double trans[6]; CPLErr aaa=poDataset->GetGeoTransform(trans); //此次分类后的tif用不到转换坐标,仅仅需要灰度值 //读取图像高程数据 double Xgeo,Ygeo; for(int i=0;i<(nImgSizeX);i++) { for(int j=0;j<(nImgSizeY);j++) { pafScanblock1 = (TTYPE *) CPLMalloc(sizeof(TTYPE)*(1)*(1)); //pafScanblock1为缓存,计算出缓存大小 poBand1->RasterIO( GF_Read, j, i,1,1,pafScanblock1,1,1,GDALDataType(poBand1->GetRasterDataType()),0, 0 ); double elevation=*pafScanblock1; num_iamge_size++; cout<<setprecision(15)<<" 高程为: "<<" "<<elevation<<endl; cout<<"下面是坐标变换系数:"<<endl; cout<<trans[0]<<" "<<trans[1]<<" "<<trans[2]<<" "<<trans[3]<<" "<<tr ans[4]<<" "<<trans[5]<<" "<<endl; myofstream<<" i="<<i<<" j="<<j<<" 类别是"<<elevation<<endl; //给关 //心的数据输出到文件 } } cout<<"总计:"<<num_iamge_size<<endl; system("pause"); delete poDataset; return 0; }
python 用cmd下载 pyqt5-tools出现错误,安装其他模块也一样
python 用cmd下载 pyqt5-tools出现错误,安装其他模块也一样 pyqt5等库我都是用离线安装的,这次安装的pyqt5-tools不知道怎么离线安装了 ![图片说明](https://img-ask.csdn.net/upload/201910/31/1572531851_935114.png) 求大神帮我看看帮我想想解决方案 出现的错误: Microsoft Windows [版本 6.1.7601] 版权所有 (c) 2009 Microsoft Corporation。保留所有权利。 C:\Users\xe100>pip3 install PyQt5-tools Collecting PyQt5-tools Downloading https://files.pythonhosted.org/packages/20/8e/c5ee7dcf8168327bb6d2 e3f830edadc91485f23049afaa709a3e019d47ef/pyqt5_tools-5.13.0.1.5-cp37-none-win_am d64.whl (67.2MB) 10% |███▌ | 7.3MB 16kB/s eta 1:00:09Exception : Traceback (most recent call last): File "d:\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 360, in _error_catcher yield File "d:\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 442, in read data = self._fp.read(amt) File "d:\python\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", li ne 62, in read data = self.__fp.read(amt) File "d:\python\lib\http\client.py", line 447, in read n = self.readinto(b) File "d:\python\lib\http\client.py", line 491, in readinto n = self.fp.readinto(b) File "d:\python\lib\socket.py", line 589, in readinto return self._sock.recv_into(b) File "d:\python\lib\ssl.py", line 1052, in recv_into return self.read(nbytes, buffer) File "d:\python\lib\ssl.py", line 911, in read return self._sslobj.read(len, buffer) socket.timeout: The read operation timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "d:\python\lib\site-packages\pip\_internal\cli\base_command.py", line 179 , in main status = self.run(options, args) File "d:\python\lib\site-packages\pip\_internal\commands\install.py", line 315 , in run resolver.resolve(requirement_set) File "d:\python\lib\site-packages\pip\_internal\resolve.py", line 131, in reso lve self._resolve_one(requirement_set, req) File "d:\python\lib\site-packages\pip\_internal\resolve.py", line 294, in _res olve_one abstract_dist = self._get_abstract_dist_for(req_to_install) File "d:\python\lib\site-packages\pip\_internal\resolve.py", line 242, in _get _abstract_dist_for self.require_hashes File "d:\python\lib\site-packages\pip\_internal\operations\prepare.py", line 3 34, in prepare_linked_requirement progress_bar=self.progress_bar File "d:\python\lib\site-packages\pip\_internal\download.py", line 878, in unp ack_url progress_bar=progress_bar File "d:\python\lib\site-packages\pip\_internal\download.py", line 702, in unp ack_http_url progress_bar) File "d:\python\lib\site-packages\pip\_internal\download.py", line 946, in _do wnload_http_url _download_url(resp, link, content_file, hashes, progress_bar) File "d:\python\lib\site-packages\pip\_internal\download.py", line 639, in _do wnload_url hashes.check_against_chunks(downloaded_chunks) File "d:\python\lib\site-packages\pip\_internal\utils\hashes.py", line 62, in check_against_chunks for chunk in chunks: File "d:\python\lib\site-packages\pip\_internal\download.py", line 607, in wri tten_chunks for chunk in chunks: File "d:\python\lib\site-packages\pip\_internal\utils\ui.py", line 159, in ite r for x in it: File "d:\python\lib\site-packages\pip\_internal\download.py", line 596, in res p_read decode_content=False): File "d:\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 494, in stream data = self.read(amt=amt, decode_content=decode_content) File "d:\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 459, in read raise IncompleteRead(self._fp_bytes_read, self.length_remaining) File "d:\python\lib\contextlib.py", line 130, in __exit__ self.gen.throw(type, value, traceback) File "d:\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 365, in _error_catcher raise ReadTimeoutError(self._pool, None, 'Read timed out.') pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files .pythonhosted.org', port=443): Read timed out. C:\Users\xe100>
日志提示Context initialization failed,查了很多未果,求大神指导
环境是jdk1.8,tomcat9.0.2 ``` 2019-12-30 19:07:11.813 [RMI TCP Connection(3)-127.0.0.1] ERROR o.s.web.context.ContextLoader - Context initialization failed org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [D:\download\RongXin_PBS-addrbook (2)\RongXin_PBS-addrbook\target\pbs_basic\WEB-INF\classes\com\ccop\core\common\page\Page.class]; nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [D:\download\RongXin_PBS-addrbook (2)\RongXin_PBS-addrbook\target\pbs_basic\WEB-INF\classes\com\ccop\core\common\page\Page.class]; nested exception is java.lang.IllegalArgumentException at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:290) ~[spring-context-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242) ~[spring-context-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84) ~[spring-context-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73) ~[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1438) ~[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428) ~[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:195) ~[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:139) ~[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:108) ~[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493) ~[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390) ~[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) ~[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) ~[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174) ~[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209) ~[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180) ~[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125) ~[spring-web-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) ~[spring-web-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130) ~[spring-context-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537) ~[spring-context-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451) ~[spring-context-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410) ~[spring-web-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) ~[spring-web-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [spring-web-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4682) [catalina.jar:9.0.22] at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5143) [catalina.jar:9.0.22] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [catalina.jar:9.0.22] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717) [catalina.jar:9.0.22] at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690) [catalina.jar:9.0.22] at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705) [catalina.jar:9.0.22] at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1728) [catalina.jar:9.0.22] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_231] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_231] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_231] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_231] at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289) [tomcat-coyote.jar:9.0.22] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [na:1.8.0_231] at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [na:1.8.0_231] at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:457) [catalina.jar:9.0.22] at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:406) [catalina.jar:9.0.22] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_231] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_231] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_231] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_231] at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289) [tomcat-coyote.jar:9.0.22] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [na:1.8.0_231] at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [na:1.8.0_231] at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468) [na:1.8.0_231] at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468) [na:1.8.0_231] at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) [na:1.8.0_231] at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309) [na:1.8.0_231] at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_231] at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1408) [na:1.8.0_231] at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) [na:1.8.0_231] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_231] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_231] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_231] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_231] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357) [na:1.8.0_231] at sun.rmi.transport.Transport$1.run(Transport.java:200) [na:1.8.0_231] at sun.rmi.transport.Transport$1.run(Transport.java:197) [na:1.8.0_231] at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_231] at sun.rmi.transport.Transport.serviceCall(Transport.java:196) [na:1.8.0_231] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573) [na:1.8.0_231] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834) [na:1.8.0_231] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688) [na:1.8.0_231] at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_231] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687) [na:1.8.0_231] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_231] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_231] at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_231] Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [D:\download\RongXin_PBS-addrbook (2)\RongXin_PBS-addrbook\target\pbs_basic\WEB-INF\classes\com\ccop\core\common\page\Page.class]; nested exception is java.lang.IllegalArgumentException at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:56) ~[spring-core-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80) ~[spring-core-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102) ~[spring-core-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:266) ~[spring-context-3.2.8.RELEASE.jar:3.2.8.RELEASE] ... 70 common frames omitted Caused by: java.lang.IllegalArgumentException: null at org.springframework.asm.ClassReader.<init>(Unknown Source) ~[spring-core-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.asm.ClassReader.<init>(Unknown Source) ~[spring-core-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.asm.ClassReader.<init>(Unknown Source) ~[spring-core-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:53) ~[spring-core-3.2.8.RELEASE.jar:3.2.8.RELEASE] ... 73 common frames omitted 30-Dec-2019 19:07:11.828 涓ラ噸 [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file 2019-12-30 19:07:11.835 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.c.s.XmlWebApplicationContext - Closing Root WebApplicationContext: startup date [Mon Dec 30 19:07:11 CST 2019]; root of context hierarchy 30-Dec-2019 19:07:11.828 涓ラ噸 [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [/pbs_basic_war_exploded] startup failed due to previous errors 2019-12-30 19:07:11.858 [RMI TCP Connection(3)-127.0.0.1] WARN o.s.w.c.s.XmlWebApplicationContext - Exception thrown from ApplicationListener handling ContextClosedEvent java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Mon Dec 30 19:07:11 CST 2019]; root of context hierarchy at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:347) [spring-context-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334) [spring-context-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1049) [spring-context-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010) [spring-context-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:586) [spring-web-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143) [spring-web-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4729) [catalina.jar:9.0.22] at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5393) [catalina.jar:9.0.22] at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) [catalina.jar:9.0.22] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:187) [catalina.jar:9.0.22] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717) [catalina.jar:9.0.22] at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690) [catalina.jar:9.0.22] at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705) [catalina.jar:9.0.22] at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1728) [catalina.jar:9.0.22] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_231] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_231] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_231] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_231] at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289) [tomcat-coyote.jar:9.0.22] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [na:1.8.0_231] at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [na:1.8.0_231] at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:457) [catalina.jar:9.0.22] at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:406) [catalina.jar:9.0.22] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_231] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_231] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_231] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_231] at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289) [tomcat-coyote.jar:9.0.22] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [na:1.8.0_231] at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [na:1.8.0_231] at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468) [na:1.8.0_231] at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468) [na:1.8.0_231] at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) [na:1.8.0_231] at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309) [na:1.8.0_231] at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_231] at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1408) [na:1.8.0_231] at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) [na:1.8.0_231] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_231] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_231] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_231] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_231] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357) [na:1.8.0_231] at sun.rmi.transport.Transport$1.run(Transport.java:200) [na:1.8.0_231] at sun.rmi.transport.Transport$1.run(Transport.java:197) [na:1.8.0_231] at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_231] at sun.rmi.transport.Transport.serviceCall(Transport.java:196) [na:1.8.0_231] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573) [na:1.8.0_231] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834) [na:1.8.0_231] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688) [na:1.8.0_231] at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_231] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687) [na:1.8.0_231] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_231] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_231] at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_231] 2019-12-30 19:07:11.874 [RMI TCP Connection(3)-127.0.0.1] WARN o.s.w.c.s.XmlWebApplicationContext - Exception thrown from LifecycleProcessor on context close java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Mon Dec 30 19:07:11 CST 2019]; root of context hierarchy at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:360) [spring-context-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1057) [spring-context-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010) [spring-context-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:586) [spring-web-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143) [spring-web-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4729) [catalina.jar:9.0.22] at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5393) [catalina.jar:9.0.22] at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) [catalina.jar:9.0.22] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:187) [catalina.jar:9.0.22] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717) [catalina.jar:9.0.22] at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690) [catalina.jar:9.0.22] at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705) [catalina.jar:9.0.22] at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1728) [catalina.jar:9.0.22] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_231] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_231] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_231] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_231] at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289) [tomcat-coyote.jar:9.0.22] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [na:1.8.0_231] at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [na:1.8.0_231] at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:457) [catalina.jar:9.0.22] at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:406) [catalina.jar:9.0.22] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_231] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_231] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_231] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_231] at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289) [tomcat-coyote.jar:9.0.22] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [na:1.8.0_231] at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [na:1.8.0_231] at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468) [na:1.8.0_231] at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468) [na:1.8.0_231] at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) [na:1.8.0_231] at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309) [na:1.8.0_231] at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_231] at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1408) [na:1.8.0_231] at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) [na:1.8.0_231] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_231] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_231] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_231] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_231] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357) [na:1.8.0_231] at sun.rmi.transport.Transport$1.run(Transport.java:200) [na:1.8.0_231] at sun.rmi.transport.Transport$1.run(Transport.java:197) [na:1.8.0_231] at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_231] at sun.rmi.transport.Transport.serviceCall(Transport.java:196) [na:1.8.0_231] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573) [na:1.8.0_231] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834) [na:1.8.0_231] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688) [na:1.8.0_231] at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_231] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687) [na:1.8.0_231] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_231] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_231] at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_231] [2019-12-30 07:07:11,889] Artifact pbs_basic:war exploded: Error during artifact deployment. See server log for details. 30-Dec-2019 19:07:14.389 淇℃伅 [Catalina-utility-1] org.apache.catalina.startup.HostConfig.deployDirectory 鎶妛eb 搴旂敤绋嬪簭閮ㄧ讲鍒扮洰褰� [D:\software\apache-tomcat-9.0.22-windows-x64\apache-tomcat-9.0.22\webapps\manager] 30-Dec-2019 19:07:14.419 淇℃伅 [Catalina-utility-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [D:\software\apache-tomcat-9.0.22-windows-x64\apache-tomcat-9.0.22\webapps\manager] has finished in [30] ms ```
关于网络链接的错误求大神指点
package com.example.urlget; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; public class MainActivity extends Activity { private static final int s=1; private static final int f=0; private EditText ed; private Button btn; private String txt; String urlString="http:192.168.1.120:8080/AndroidTest/Message.txt"; private Handler mHandler=new Handler(){ public void handleMessage(Message msg){ switch (msg.what) { case s:ed.setText(txt); break; case f:ed.setText("Download the file Failure!"); break; } } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ed=(EditText) findViewById(R.id.ed); btn=(Button) findViewById(R.id.btn); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub GetURlResources(); } }); } private void GetURlResources() { // TODO Auto-generated method stub new Thread(new Runnable() { @Override public void run() { try { Log.v("log", "hello"); URL myUrl=new URL(urlString); HttpURLConnection myConn=(HttpURLConnection) myUrl.openConnection(); Log.v("log", "hello1"); myConn.setConnectTimeout(3000); Log.v("log", "hello2"); InputStreamReader in=new InputStreamReader(myConn.getInputStream()); Log.v("log", "hello3"); BufferedReader buffer=new BufferedReader(in); String inputline =null; StringBuffer pageBuffer=new StringBuffer(); Log.v("log", "hello4"); while((inputline=buffer.readLine())!=null){ pageBuffer.append(inputline+"\n"); } Log.v("log", "hello5"); txt=new String(pageBuffer.toString().getBytes("UTF-8")); txt=txt.substring(0,txt.length()-1); mHandler.sendEmptyMessage(0); in.close(); buffer.close(); myConn.disconnect(); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }).start(); } } 这个在手机上运行logcat怎么显示 E/dalvikvm(20427): threadid=11: exiting,name=Thread-5433新手求大神指点
一个百度拇指医生爬虫,想要先实现爬取某个问题的所有链接,但是爬不出来东西。求各位大神帮忙看一下这是为什么?
#写在前面的话 在这个爬虫里我想实现把百度拇指医生里关于“咳嗽”的链接全部爬取下来,下一步要进行的是把爬取到的每个链接里的items里面的内容爬取下来,但是我在第一步就卡住了,求各位大神帮我看一下吧。之前刚刚发了一篇问答,但是不知道怎么回事儿,现在找不到了,(貌似是被删了...?)救救小白吧!感激不尽! 这个是我的爬虫的结构 ![图片说明](https://img-ask.csdn.net/upload/201911/27/1574787999_274479.png) ##ks: ``` # -*- coding: utf-8 -*- import scrapy from kesou.items import KesouItem from scrapy.selector import Selector from scrapy.spiders import Spider from scrapy.http import Request ,FormRequest import pymongo class KsSpider(scrapy.Spider): name = 'ks' allowed_domains = ['kesou,baidu.com'] start_urls = ['https://www.baidu.com/s?wd=%E5%92%B3%E5%97%BD&pn=0&oq=%E5%92%B3%E5%97%BD&ct=2097152&ie=utf-8&si=muzhi.baidu.com&rsv_pq=980e0c55000e2402&rsv_t=ed3f0i5yeefxTMskgzim00cCUyVujMRnw0Vs4o1%2Bo%2Bohf9rFXJvk%2FSYX%2B1M'] def parse(self, response): item = KesouItem() contents = response.xpath('.//h3[@class="t"]') for content in contents: url = content.xpath('.//a/@href').extract()[0] item['url'] = url yield item if self.offset < 760: self.offset += 10 yield scrapy.Request(url = "https://www.baidu.com/s?wd=%E5%92%B3%E5%97%BD&pn=" + str(self.offset) + "&oq=%E5%92%B3%E5%97%BD&ct=2097152&ie=utf-8&si=muzhi.baidu.com&rsv_pq=980e0c55000e2402&rsv_t=ed3f0i5yeefxTMskgzim00cCUyVujMRnw0Vs4o1%2Bo%2Bohf9rFXJvk%2FSYX%2B1M",callback=self.parse,dont_filter=True) ``` ##items: ``` # -*- coding: utf-8 -*- # Define here the models for your scraped items # # See documentation in: # https://docs.scrapy.org/en/latest/topics/items.html import scrapy class KesouItem(scrapy.Item): # 问题ID question_ID = scrapy.Field() # 问题描述 question = scrapy.Field() # 医生回答发表时间 answer_pubtime = scrapy.Field() # 问题详情 description = scrapy.Field() # 医生姓名 doctor_name = scrapy.Field() # 医生职位 doctor_title = scrapy.Field() # 医生所在医院 hospital = scrapy.Field() ``` ##middlewares: ``` # -*- coding: utf-8 -*- # Define here the models for your spider middleware # # See documentation in: # https://docs.scrapy.org/en/latest/topics/spider-middleware.html from scrapy import signals class KesouSpiderMiddleware(object): # Not all methods need to be defined. If a method is not defined, # scrapy acts as if the spider middleware does not modify the # passed objects. @classmethod def from_crawler(cls, crawler): # This method is used by Scrapy to create your spiders. s = cls() crawler.signals.connect(s.spider_opened, signal=signals.spider_opened) return s def process_spider_input(self, response, spider): # Called for each response that goes through the spider # middleware and into the spider. # Should return None or raise an exception. return None def process_spider_output(self, response, result, spider): # Called with the results returned from the Spider, after # it has processed the response. # Must return an iterable of Request, dict or Item objects. for i in result: yield i def process_spider_exception(self, response, exception, spider): # Called when a spider or process_spider_input() method # (from other spider middleware) raises an exception. # Should return either None or an iterable of Request, dict # or Item objects. pass def process_start_requests(self, start_requests, spider): # Called with the start requests of the spider, and works # similarly to the process_spider_output() method, except # that it doesn’t have a response associated. # Must return only requests (not items). for r in start_requests: yield r def spider_opened(self, spider): spider.logger.info('Spider opened: %s' % spider.name) class KesouDownloaderMiddleware(object): # Not all methods need to be defined. If a method is not defined, # scrapy acts as if the downloader middleware does not modify the # passed objects. @classmethod def from_crawler(cls, crawler): # This method is used by Scrapy to create your spiders. s = cls() crawler.signals.connect(s.spider_opened, signal=signals.spider_opened) return s def process_request(self, request, spider): # Called for each request that goes through the downloader # middleware. # Must either: # - return None: continue processing this request # - or return a Response object # - or return a Request object # - or raise IgnoreRequest: process_exception() methods of # installed downloader middleware will be called return None def process_response(self, request, response, spider): # Called with the response returned from the downloader. # Must either; # - return a Response object # - return a Request object # - or raise IgnoreRequest return response def process_exception(self, request, exception, spider): # Called when a download handler or a process_request() # (from other downloader middleware) raises an exception. # Must either: # - return None: continue processing this exception # - return a Response object: stops process_exception() chain # - return a Request object: stops process_exception() chain pass def spider_opened(self, spider): spider.logger.info('Spider opened: %s' % spider.name) ``` ##piplines: ``` # -*- coding: utf-8 -*- # Define your item pipelines here # # Don't forget to add your pipeline to the ITEM_PIPELINES setting # See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html import pymongo from scrapy.utils.project import get_project_settings settings = get_project_settings() class KesouPipeline(object): def __init__(self): host = settings["MONGODB_HOST"] port = settings["MONGODB_PORT"] dbname = settings["MONGODB_DBNAME"] sheetname= settings["MONGODB_SHEETNAME"] # 创建MONGODB数据库链接 client = pymongo.MongoClient(host = host, port = port) # 指定数据库 mydb = client[dbname] # 存放数据的数据库表名 self.sheet = mydb[sheetname] def process_item(self, item, spider): data = dict(item) self.sheet.insert(data) return item ``` ##settings: ``` # -*- coding: utf-8 -*- # Scrapy settings for kesou project # # For simplicity, this file contains only settings considered important or # commonly used. You can find more settings consulting the documentation: # # https://docs.scrapy.org/en/latest/topics/settings.html # https://docs.scrapy.org/en/latest/topics/downloader-middleware.html # https://docs.scrapy.org/en/latest/topics/spider-middleware.html BOT_NAME = 'kesou' SPIDER_MODULES = ['kesou.spiders'] NEWSPIDER_MODULE = 'kesou.spiders' # Crawl responsibly by identifying yourself (and your website) on the user-agent #USER_AGENT = 'kesou (+http://www.yourdomain.com)' # Obey robots.txt rules ROBOTSTXT_OBEY = False # Configure maximum concurrent requests performed by Scrapy (default: 16) #CONCURRENT_REQUESTS = 32 # Configure a delay for requests for the same website (default: 0) # See https://docs.scrapy.org/en/latest/topics/settings.html#download-delay # See also autothrottle settings and docs #DOWNLOAD_DELAY = 3 # The download delay setting will honor only one of: #CONCURRENT_REQUESTS_PER_DOMAIN = 16 #CONCURRENT_REQUESTS_PER_IP = 16 # Disable cookies (enabled by default) COOKIES_ENABLED = False # Disable Telnet Console (enabled by default) #TELNETCONSOLE_ENABLED = False USER_AGENT="Mozilla/5.0 (Windows NT 10.0; WOW64; rv:67.0) Gecko/20100101 Firefox/67.0" # Override the default request headers: #DEFAULT_REQUEST_HEADERS = { # 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', # 'Accept-Language': 'en', #} # Enable or disable spider middlewares # See https://docs.scrapy.org/en/latest/topics/spider-middleware.html #SPIDER_MIDDLEWARES = { # 'kesou.middlewares.KesouSpiderMiddleware': 543, #} # Enable or disable downloader middlewares # See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html #DOWNLOADER_MIDDLEWARES = { # 'kesou.middlewares.KesouDownloaderMiddleware': 543, #} # Enable or disable extensions # See https://docs.scrapy.org/en/latest/topics/extensions.html #EXTENSIONS = { # 'scrapy.extensions.telnet.TelnetConsole': None, #} # Configure item pipelines # See https://docs.scrapy.org/en/latest/topics/item-pipeline.html ITEM_PIPELINES = { 'kesou.pipelines.KesouPipeline': 300, } # MONGODB 主机名 MONGODB_HOST = "127.0.0.1" # MONGODB 端口号 MONGODB_PORT = 27017 # 数据库名称 MONGODB_DBNAME = "ks" # 存放数据的表名称 MONGODB_SHEETNAME = "ks_urls" # Enable and configure the AutoThrottle extension (disabled by default) # See https://docs.scrapy.org/en/latest/topics/autothrottle.html #AUTOTHROTTLE_ENABLED = True # The initial download delay #AUTOTHROTTLE_START_DELAY = 5 # The maximum download delay to be set in case of high latencies #AUTOTHROTTLE_MAX_DELAY = 60 # The average number of requests Scrapy should be sending in parallel to # each remote server #AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0 # Enable showing throttling stats for every response received: #AUTOTHROTTLE_DEBUG = False # Enable and configure HTTP caching (disabled by default) # See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings #HTTPCACHE_ENABLED = True #HTTPCACHE_EXPIRATION_SECS = 0 #HTTPCACHE_DIR = 'httpcache' #HTTPCACHE_IGNORE_HTTP_CODES = [] #HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage' ``` ##run.py: ``` # -*- coding: utf-8 -*- from scrapy import cmdline cmdline.execute("scrapy crawl ks".split()) ``` ##这个是运行出来的结果: ``` PS D:\scrapy_project\kesou> scrapy crawl ks 2019-11-27 00:14:17 [scrapy.utils.log] INFO: Scrapy 1.7.3 started (bot: kesou) 2019-11-27 00:14:17 [scrapy.utils.log] INFO: Versions: lxml 4.3.2.0, libxml2 2.9.9, cssselect 1.1.0, parsel 1.5.2, w3lib 1.21.0, Twis.7.0, Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)], pyOpenSSL 19.0.0 (OpenSSL 1.1.1b 26 Feb 2019), cryphy 2.6.1, Platform Windows-10-10.0.18362-SP0 2019-11-27 00:14:17 [scrapy.crawler] INFO: Overridden settings: {'BOT_NAME': 'kesou', 'COOKIES_ENABLED': False, 'NEWSPIDER_MODULE': 'spiders', 'SPIDER_MODULES': ['kesou.spiders'], 'USER_AGENT': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:67.0) Gecko/20100101 Firefox/67 2019-11-27 00:14:17 [scrapy.extensions.telnet] INFO: Telnet Password: 051629c46f34abdf 2019-11-27 00:14:17 [scrapy.middleware] INFO: Enabled extensions: ['scrapy.extensions.corestats.CoreStats', 'scrapy.extensions.telnet.TelnetConsole', 'scrapy.extensions.logstats.LogStats'] 2019-11-27 00:14:19 [scrapy.middleware] INFO: Enabled downloader middlewares: ['scrapy.downloadermiddlewares.httpauth.HttpAuthMiddleware', 'scrapy.downloadermiddlewares.downloadtimeout.DownloadTimeoutMiddleware', 'scrapy.downloadermiddlewares.defaultheaders.DefaultHeadersMiddleware', 'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware', 'scrapy.downloadermiddlewares.retry.RetryMiddleware', 'scrapy.downloadermiddlewares.redirect.MetaRefreshMiddleware', 'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware', 'scrapy.downloadermiddlewares.redirect.RedirectMiddleware', 'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware', 'scrapy.downloadermiddlewares.stats.DownloaderStats'] 2019-11-27 00:14:19 [scrapy.middleware] INFO: Enabled spider middlewares: ['scrapy.spidermiddlewares.httperror.HttpErrorMiddleware', 'scrapy.spidermiddlewares.offsite.OffsiteMiddleware', 'scrapy.spidermiddlewares.referer.RefererMiddleware', 'scrapy.spidermiddlewares.urllength.UrlLengthMiddleware', 'scrapy.spidermiddlewares.depth.DepthMiddleware'] 2019-11-27 00:14:19 [scrapy.middleware] INFO: Enabled item pipelines: ['kesou.pipelines.KesouPipeline'] 2019-11-27 00:14:19 [scrapy.core.engine] INFO: Spider opened 2019-11-27 00:14:19 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min) 2019-11-27 00:14:19 [scrapy.extensions.telnet] INFO: Telnet console listening on 127.0.0.1:6023 2019-11-27 00:14:20 [scrapy.core.engine] DEBUG: Crawled (200) <GET https://www.baidu.com/s?wd=%E5%92%B3%E5%97%BD&pn=0&oq=%E5%92%B3%E5&ct=2097152&ie=utf-8&si=muzhi.baidu.com&rsv_pq=980e0c55000e2402&rsv_t=ed3f0i5yeefxTMskgzim00cCUyVujMRnw0Vs4o1%2Bo%2Bohf9rFXJvk%2FSYX% (referer: None) 2019-11-27 00:14:20 [scrapy.core.scraper] ERROR: Spider error processing <GET https://www.baidu.com/s?wd=%E5%92%B3%E5%97%BD&pn=0&oq=%B3%E5%97%BD&ct=2097152&ie=utf-8&si=muzhi.baidu.com&rsv_pq=980e0c55000e2402&rsv_t=ed3f0i5yeefxTMskgzim00cCUyVujMRnw0Vs4o1%2Bo%2Bohf9rFFSYX%2B1M> (referer: None) Traceback (most recent call last): File "d:\anaconda3\lib\site-packages\scrapy\utils\defer.py", line 102, in iter_errback yield next(it) File "d:\anaconda3\lib\site-packages\scrapy\core\spidermw.py", line 84, in evaluate_iterable for r in iterable: File "d:\anaconda3\lib\site-packages\scrapy\spidermiddlewares\offsite.py", line 29, in process_spider_output for x in result: File "d:\anaconda3\lib\site-packages\scrapy\core\spidermw.py", line 84, in evaluate_iterable for r in iterable: File "d:\anaconda3\lib\site-packages\scrapy\spidermiddlewares\referer.py", line 339, in <genexpr> return (_set_referer(r) for r in result or ()) File "d:\anaconda3\lib\site-packages\scrapy\core\spidermw.py", line 84, in evaluate_iterable for r in iterable: File "d:\anaconda3\lib\site-packages\scrapy\spidermiddlewares\urllength.py", line 37, in <genexpr> return (r for r in result or () if _filter(r)) File "d:\anaconda3\lib\site-packages\scrapy\core\spidermw.py", line 84, in evaluate_iterable for r in iterable: File "d:\anaconda3\lib\site-packages\scrapy\spidermiddlewares\depth.py", line 58, in <genexpr> return (r for r in result or () if _filter(r)) File "D:\scrapy_project\kesou\kesou\spiders\ks.py", line 19, in parse item['url'] = url File "d:\anaconda3\lib\site-packages\scrapy\item.py", line 73, in __setitem__ (self.__class__.__name__, key)) KeyError: 'KesouItem does not support field: url' 2019-11-27 00:14:20 [scrapy.core.engine] INFO: Closing spider (finished) 2019-11-27 00:14:20 [scrapy.statscollectors] INFO: Dumping Scrapy stats: {'downloader/request_bytes': 438, 'downloader/request_count': 1, 'downloader/request_method_count/GET': 1, 'downloader/response_bytes': 68368, 'downloader/response_count': 1, 'downloader/response_status_count/200': 1, 'elapsed_time_seconds': 0.992207, 'finish_reason': 'finished', 'finish_time': datetime.datetime(2019, 11, 26, 16, 14, 20, 855804), 'log_count/DEBUG': 1, 2019-11-27 00:14:20 [scrapy.statscollectors] INFO: Dumping Scrapy stats: {'downloader/request_bytes': 438, 'downloader/request_count': 1, 'downloader/request_method_count/GET': 1, 'downloader/response_bytes': 68368, 'downloader/response_count': 1, 'downloader/response_status_count/200': 1, 'elapsed_time_seconds': 0.992207, 'finish_reason': 'finished', 'finish_time': datetime.datetime(2019, 11, 26, 16, 14, 20, 855804), 'log_count/DEBUG': 1, 'log_count/ERROR': 1, 'log_count/INFO': 10, 'response_received_count': 1, 'scheduler/dequeued': 1, 'scheduler/dequeued/memory': 1, 'scheduler/enqueued': 1, 'scheduler/enqueued/memory': 1, 'spider_exceptions/KeyError': 1, 'start_time': datetime.datetime(2019, 11, 26, 16, 14, 19, 863597)} 2019-11-27 00:14:21 [scrapy.core.engine] INFO: Spider closed (finished) ```
用okhttp实现断点续传,网络请求进OnFailure,急急急,大神们
ProgressDownloader类 ``` public class ProgressDownloader { public static final String TAG = "TestProgressDownloader"; private ProgressResponseBody.ProgressListener progressListener; private String url; private OkHttpClient client; private File destination; private Call call; public ProgressDownloader(String url, File destination, ProgressResponseBody.ProgressListener progressListener) { this.url = url; this.destination = destination; this.progressListener = progressListener; //在下载、暂停后的继续下载中可复用同一个client对象 client = getProgressClient(); } //每次下载需要新建新的Call对象 private Call newCall(long startPoints) { Request request = new Request.Builder() .get() .url(url) .header("RANGE", "bytes=" + startPoints + "-")//断点续传要用到的,指示下载的区间 .build(); return client.newCall(request); } public OkHttpClient getProgressClient() { // 拦截器,用上ProgressResponseBody Interceptor interceptor = new Interceptor() { @Override public Response intercept(Chain chain) throws IOException { Response originalResponse = chain.proceed(chain.request()); return originalResponse.newBuilder() .body(new ProgressResponseBody(originalResponse.body(), progressListener)) .build(); } }; return new OkHttpClient.Builder() .addNetworkInterceptor(interceptor) .build(); } //startsPoint指定开始下载的点 public void download(final long startsPoint) { call = newCall(startsPoint); call.enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { Log.e("=======================","fail"); } @Override public void onResponse(Call call, Response response) throws IOException { Log.e("=======================","pass"); } }); } public void pause() { if(call!=null){ call.cancel(); } } private void save(Response response, long startsPoint) { ResponseBody body = response.body(); InputStream in = body.byteStream(); FileChannel channelOut = null; // 随机访问文件,可以指定断点续传的起始位置 RandomAccessFile randomAccessFile = null; try { randomAccessFile = new RandomAccessFile(destination, "rwd"); //Chanel NIO中的用法,由于RandomAccessFile没有使用缓存策略,直接使用会使得下载速度变慢,亲测缓存下载3.3秒的文件,用普通的RandomAccessFile需要20多秒。 channelOut = randomAccessFile.getChannel(); // 内存映射,直接使用RandomAccessFile,是用其seek方法指定下载的起始位置,使用缓存下载,在这里指定下载位置。 MappedByteBuffer mappedBuffer = channelOut.map(FileChannel.MapMode.READ_WRITE, startsPoint, body.contentLength()); byte[] buffer = new byte[1024]; int len; while ((len = in.read(buffer)) != -1) { mappedBuffer.put(buffer, 0, len); } } catch (IOException e) { e.printStackTrace(); }finally { try { in.close(); if (channelOut != null) { channelOut.close(); } if (randomAccessFile != null) { randomAccessFile.close(); } } catch (IOException e) { e.printStackTrace(); } } } } ``` MainActivity类 ``` /** * 1.添加依赖 * 2.生成带进度监听的ProgressResponseBody * 3.创建ProgressDownloader * 4.清单文件中添加网络权限和文件访问权限 */ public class MainActivity extends AppCompatActivity implements ProgressResponseBody.ProgressListener{ public static final String TAG = "MainActivity"; public static final String PACKAGE_URL = "http://gdown.baidu.com/data/wisegame/df65a597122796a4/weixin_821.apk"; @Bind(R.id.progressBar) ProgressBar progressBar; private long breakPoints; private ProgressDownloader downloader; private File file; private long totalBytes; private long contentLength; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); } @OnClick({R.id.downloadButton, R.id.cancel_button, R.id.continue_button}) public void onClick(View view) { switch (view.getId()) { case R.id.downloadButton: // 新下载前清空断点信息 breakPoints = 0L; file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "sample.apk"); downloader = new ProgressDownloader(PACKAGE_URL, file, this); downloader.download(0L); break; case R.id.cancel_button: downloader.pause(); Toast.makeText(this, "下载暂停", Toast.LENGTH_SHORT).show(); // 存储此时的totalBytes,即断点位置。 breakPoints = totalBytes; break; case R.id.continue_button: downloader.download(breakPoints); break; } } @Override public void onPreExecute(long contentLength) { // 文件总长只需记录一次,要注意断点续传后的contentLength只是剩余部分的长度 if (this.contentLength == 0L) { this.contentLength = contentLength; progressBar.setMax((int) (contentLength / 1024)); } } @Override public void update(long totalBytes, boolean done) { // 注意加上断点的长度 this.totalBytes = totalBytes + breakPoints; progressBar.setProgress((int) (totalBytes + breakPoints) / 1024); if (done) { // 切换到主线程 Observable .empty() .observeOn(AndroidSchedulers.mainThread()) .doOnCompleted(new Action0() { @Override public void call() { Toast.makeText(MainActivity.this, "下载完成", Toast.LENGTH_SHORT).show(); } }) .subscribe(); } } } ``` 代码链接:https://blog.csdn.net/halaoda/article/details/78502693
Studio用xutils 的HttpUtils进行下载视频时安卓6.0的系统下载失败大神们帮忙看看
用xutils的Httputils 下载视频 其他安卓系统都可以实现。6.0的就是下载卡死。 HttpUtils http = new HttpUtils(); url = list.get(position).getFile_name(); resultPath = WinnerApplication.DEFAULT_VOICE_FOLDER + FileUtils.getFileName(url) + ".youzhi";//下载文件的跟路径 if ("缓存完成".equals(bufferVideo.getText()) == false) { PRogDialog.showProgressDialog(context, "请稍后"); } //下载视频文件 handler = http.download(url, resultPath, true, false, new RequestCallBack<File>() { @Override public void onStart() { super.onStart(); Log.e(TAG, "刚开始加载时的回调-----onStart"); bufferVideo.setText(context.getResources().getString(R.string.video_load)); } @Override public void onLoading(long total, long current, boolean isUploading) { super.onLoading(total, current, isUploading); Log.e(TAG, "正在加载中的回调----onLoading"); bufferVideo.setText(context.getResources().getString(R.string.video_download)); // bufferVideo.setText((int) (current * 100 / total) + "%");//显示下载的百分比 PRogDialog.showMessage("缓冲中 " + (int) (current * 100 / total) + "%"); } @Override public void onSuccess(ResponseInfo<File> arg0) { // Intent it = new Intent(context,VideoInfoActivity.class);//下载成功跳转到观看视频界面 // it.putExtra("data", arg0.result.getAbsolutePath()); // startActivity(it); // finish();item_video_button_shape Log.e(TAG, "加载成功后的回调----onSuccess"); bufferVideo.setText("缓存完成"); bufferVideo.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.item_playvideo_button_shape)); retuteURL_string.set(position, arg0.result.getAbsolutePath()); //retuteURL = arg0.result.getAbsolutePath(); playTextView.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.item_video_button_shape)); deleteVideo.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.item_video_button_shape)); PRogDialog.ProgressDialogDismiss(); } @Override public void onFailure(HttpException arg0, String arg1) { Log.e(TAG, "onFailure"); Log.i("fail-------------------", arg1); if (FileUtils.isFileExist(resultPath)) { //如果文件已存在,就直接观看 // Intent it = new Intent(context,VideoInfoActivity.class); // it.putExtra("data", resultPath); // startActivity(it); // finish(); Log.e(TAG, "如果文件已经存在直接观看---FileUtils.isFileExist(resultPath)"); retuteURL_string.set(position, resultPath); // retuteURL_string.get(position); // retuteURL = resultPath; bufferVideo.setText("缓存完成"); playTextView.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.item_video_button_shape)); } else { Log.e(TAG, "else----下载失败..."); bufferVideo.setText("下载失败..."); //video_wait.setVisibility(View.GONE); } } @Override public void onCancelled() { super.onCancelled(); } }); 代码如上 ![图片说明](https://img-ask.csdn.net/upload/201606/07/1465262045_933128.png) 报错 直接onStart 然后等待1-2秒然后直接走的onFailure。 后来又单独写了个下载视频的小Demo 代码照这个扒的,居然可以下载。说明系统和代码都没有问题啊。 但是为什么6.0的 在项目那个就下载不来呢。。。。。。。大神恩帮帮忙
JAVA中导出excel的公用类的方法怎么调用?
1.我想导出前端查询后的数据,然后将数据导出到excel中,在网上查到有一个公用的方法,我创建了,但是我不会调用。请各位大神帮助下,谢谢了。刚开始学习java的小白。 2.疑问:controller(这个不会写)怎么调用这个方法呢? 3.环境:Java后端+vue前端(前端过滤后的数据进行导出) 如下为controller,这个确实不会写,请各位大神帮助下。谢谢。 ``` @RequestMapping("/exportExcel") //@ApiOperation("数据导出excel") @ResponseBody public R download(@RequestParam Map<String, Object> params){ //exportSsExcel(String tempPath, String path, HttpServletResponse response, List<T> list, int count) //获取日期类型根据类型分发业务 String energy_name = MapUtil.getStr(map,"tempPath"); String to_build = MapUtil.getStr(map,"path"); } ``` 如下为共用类ExcelUtils中的导出方法。 ``` public void exportSsExcel(String tempPath, String path, HttpServletResponse response, List<T> list, int count) { File newFile = createNewFile(tempPath, path); InputStream is = null; HSSFWorkbook workbook = null; HSSFSheet sheet = null; try { is = new FileInputStream(newFile);// 将excel文件转为输入流 workbook = new HSSFWorkbook(is);// 创建个workbook, // 获取第一个sheet sheet = workbook.getSheetAt(0); } catch (Exception e1) { e1.printStackTrace(); } if (sheet != null) { try { // 写数据 FileOutputStream fos = new FileOutputStream(newFile); HSSFRow row = sheet.getRow(0); if (row == null) { row = sheet.createRow(0); } HSSFCell cell = row.getCell(0); if (cell == null) { cell = row.createCell(0); } //cell.setCellValue("我是标题"); for (int i = 0; i < list.size(); i++) { T vo1 = list.get(i); row = sheet.createRow(i+count); //从第count行开始 //这里就可以使用sysUserMapper,做相应的操作 Field[] fields=vo1.getClass().getDeclaredFields(); for(int j=0;j<fields.length;j++){ String firstLetter = fields[j].getName().substring(0, 1).toUpperCase(); String getter = "get" + firstLetter + fields[j].getName().substring(1); Method method = vo1.getClass().getMethod(getter, new Class[] {}); if(fields[j].getGenericType().toString().equals("class java.util.Date")){ Object value =method.invoke(vo1, new Object[] {}); if(value!=null){ Date date =(Date)value; createRowAndCell(format.format(date), row, cell, j); }else { createRowAndCell(value, row, cell, j); } }else { createRowAndCell(method.invoke(vo1, new Object[] {}), row, cell, j); } } } workbook.write(fos); fos.flush(); fos.close(); // 下载 InputStream fis = new BufferedInputStream(new FileInputStream( newFile)); byte[] buffer = new byte[fis.available()]; fis.read(buffer); fis.close(); response.reset(); response.setContentType("text/html;charset=UTF-8"); OutputStream toClient = new BufferedOutputStream( response.getOutputStream()); response.setContentType("application/x-msdownload"); String newName = URLEncoder.encode( "防火漏电" + System.currentTimeMillis() + ".xls", "UTF-8"); response.addHeader("Content-Disposition", "attachment;filename=\"" + newName + "\""); response.addHeader("Content-Length", "" + newFile.length()); toClient.write(buffer); toClient.flush(); } catch (Exception e) { e.printStackTrace(); } finally { try { if (null != is) { is.close(); } } catch (Exception e) { e.printStackTrace(); } } } // 删除创建的新文件 this.deleteFile(newFile); } ```
请大神指教!shareSDK第三方登录,返回了用户登录信息,但是一直报空指针异常,可是有返回值
这是我的代码,先点击一个图片按钮,然后跳转到授权界面,当授权完成的时候,再把值返回在这个类里面,但是运行的时候一直报这句left_menu_fragment_textview.setText(userInfo.getUserName());是空指针异常,这是怎么回事 public class LeftMenuFragment extends BaseFragment { private ImageButton left_menu_fragment_imagebutton; private ListView left_menu_fragment_listview; private String[] itemname = new String[] { "设置文字大小", "收藏", "检查更新" }; /************************************ 后面增加的方法 **********************************************/ private OnLoginListener signupListener; private Platform platform; private String picturePath; private UserInfo userInfo = new UserInfo(); /** 加载用户icon */ private static final int LOAD_USER_ICON = 2; /** 图片名字 */ private static final String PICTURE_NAME = "userIcon.jpg"; private TextView left_menu_fragment_textview; /**********************************************************************************/ @Override public View initview() { View view = View.inflate(mActivity, R.layout.left_menu_fragment, null); left_menu_fragment_imagebutton = (ImageButton) view .findViewById(R.id.left_menu_fragment_imagebutton); left_menu_fragment_listview = (ListView) view .findViewById(R.id.left_menu_fragment_listview); left_menu_fragment_textview = (TextView) view .findViewById(R.id.left_menu_fragment_textview); left_menu_fragment_listview.setAdapter(new myListAdapter()); left_menu_fragment_imagebutton .setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Log.i("pan", "已经点击跳转界面"); Intent intent = new Intent(); intent.setClass(mActivity, AuthorizationLoginActivity.class); mActivity.startActivity(intent); } }); return view; } /** * 初始化数据 */ @Override public void initData() { if (platform != null) { userInfo.setUserIcon(platform.getDb().getUserIcon()); userInfo.setUserName(platform.getDb().getUserName()); Log.i("pan", "leftMenuFragment中的username" + userInfo.getUserName()); Log.i("pan", "leftMenuFragment中的icon" + userInfo.getUserIcon()); if (userInfo.getUserName() != null) { Log.i("pan", "leftMenuFragment中的username222222" + userInfo.getUserName()); left_menu_fragment_textview.setText(userInfo.getUserName()); } } if (!TextUtils.isEmpty(userInfo.getUserIcon())) { Log.i("pan", "执行进入了获取icon方法吗"); loadIcon(); } // 初始化照片保存地址 if (Environment.getExternalStorageState().equals( Environment.MEDIA_MOUNTED)) { String thumPicture = Environment.getExternalStorageDirectory() .getAbsolutePath() + "/" + mActivity.getPackageName() + "/download"; File pictureParent = new File(thumPicture); File pictureFile = new File(pictureParent, PICTURE_NAME); if (!pictureParent.exists()) { pictureParent.mkdirs(); } try { if (!pictureFile.exists()) { pictureFile.createNewFile(); } } catch (Exception e) { e.printStackTrace(); } picturePath = pictureFile.getAbsolutePath(); Log.e("picturePath ==>>", picturePath); } else { Log.e("change user icon ==>>", "there is not sdcard!"); } // Bundle bundle = mActivity.getIntent().getExtras(); // if (bundle != null) { // // Log.i("pan", "LeftMenuFragment中的res值:" + bundle.get("myMap")); // Map<String, Object> hashmap = (Map<String, Object>) // bundle.getSerializable("myMap"); // String name = (String) hashmap.get("nickname"); // Log.i("pan", "LeftMenuFragment中的res值:" + hashmap); // Log.i("pan", "LeftMenuFragment中的name值:" + name); // } } private Handler handler = new Handler() { public void handleMessage(Message msg) { switch (msg.what) { case LOAD_USER_ICON: left_menu_fragment_imagebutton.setImageURI(Uri .parse(picturePath)); break; default: break; } }; }; /** * 加载头像 */ public void loadIcon() { final String imageUrl = platform.getDb().getUserIcon(); new Thread(new Runnable() { @Override public void run() { try { URL picUrl = new URL(imageUrl); Bitmap userIcon = BitmapFactory.decodeStream(picUrl .openStream()); FileOutputStream b = null; try { b = new FileOutputStream(picturePath); userIcon.compress(Bitmap.CompressFormat.JPEG, 100, b);// 把数据写入文件 } catch (FileNotFoundException e) { e.printStackTrace(); } finally { try { b.flush(); b.close(); } catch (IOException e) { e.printStackTrace(); } } userInfo.setUserIcon(picturePath); Message msg = new Message(); msg.what = LOAD_USER_ICON; // UIHandler.sendMessage(msg); handler.sendMessage(msg); } catch (Exception e) { e.printStackTrace(); } } }).start(); } public boolean handleMessage(Message msg) { switch (msg.what) { case LOAD_USER_ICON: left_menu_fragment_imagebutton.setImageURI(Uri.parse(picturePath)); break; default: break; } return false; } /** * listview的适配器 * * @author Administrator * */ class myListAdapter extends BaseAdapter { private TextView text; @Override public int getCount() { // TODO Auto-generated method stub return itemname.length; } @Override public Object getItem(int position) { return itemname[position]; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = View.inflate(mActivity, R.layout.left_menu_fragment_listview, null); } text = (TextView) convertView .findViewById(R.id.left_menu_fragment_listview_textview); text.setText(itemname[position]); return convertView; } } /****************************************************************************************/ /** 设置授权回调,用于判断是否进入注册 */ public void setOnLoginListener(OnLoginListener l) { this.signupListener = l; } public void setPlatform(String platName) { Log.i("pan", "platName的值为:" + platName); platform = ShareSDK.getPlatform(platName); initData(); } 这下面是打印的值: 10-30 09:11:52.480: I/pan(8062): leftMenuFragment中的username额路的快乐 10-30 09:11:52.480: I/pan(8062): leftMenuFragment中的iconhttp://q.qlogo.cn/qqapp/100371282/C9F7933B7F1457206982CCF2EC3548F9/40 10-30 09:11:52.480: I/pan(8062): leftMenuFragment中的username222222额路的快乐 10-30 09:11:52.480: I/pan(8062): 执行进入了获取icon方法吗 这下面是错误的提示: 10-30 09:11:52.490: E/AndroidRuntime(8062): java.lang.NullPointerException 10-30 09:11:52.490: E/AndroidRuntime(8062): at com.pan.foucstoday.fragment.LeftMenuFragment.initData(LeftMenuFragment.java:121) 10-30 09:11:52.490: E/AndroidRuntime(8062): at com.pan.foucstoday.fragment.LeftMenuFragment.setPlatform(LeftMenuFragment.java:270) 10-30 09:11:52.490: E/AndroidRuntime(8062): at com.pan.foucstoday.AuthorizationLoginActivity.handleMessage(AuthorizationLoginActivity.java:201) 10-30 09:11:52.490: E/AndroidRuntime(8062): at com.mob.tools.utils.UIHandler.handleMessage(Unknown Source) 10-30 09:11:52.490: E/AndroidRuntime(8062): at com.mob.tools.utils.UIHandler.access$000(Unknown Source)
我前端页面上传了视频到 项目的tomcat服务器上 ,数据库保存的地址,但是我在前期怎么访问这个视频啊。求大神指点
后台上传代码 ``` public int addCourseWare(HttpServletRequest request){ //解析请求中的数据 MultipartHttpServletRequest mpRequest = (MultipartHttpServletRequest) request; String courseWare_name = request.getParameter("courseWare_name"); String course_id =request.getParameter("course_name"); String courseWare_type = request.getParameter("courseWare_type"); String courseWare_introduction = request.getParameter("courseWare_introduction"); //将上传的数据写入CourseWareCnd对象 CourseWareCnd cnd = new CourseWareCnd(); cnd.setCourseWare_name(courseWare_name); cnd.setCourse_id(Integer.parseInt(course_id)); cnd.setCourseWare_type(courseWare_type); cnd.setCourseWare_introduction(courseWare_introduction); //获取上传文件的文件名 MultipartFile file = mpRequest.getFile("video"); String name = file.getOriginalFilename(); //获取项目路径 String ctxPath = request.getSession().getServletContext().getRealPath("/"); String path=ctxPath+name; cnd.setVideo(path); System.out.println("-------------"+path); File f = new File(ctxPath); if (!f.exists()) {//判断文件夹是否存在,不存在创建 f.mkdir(); } try { file.transferTo(new File(path));//将数据写到该位置 } catch (IOException e) { e.printStackTrace(); } int result = courseWareMapper.addCourseWare(cnd); return result; } ``` 前端HTML页面 ``` <div class="ibox float-e-margins"> <div class="ibox-title"> <h5>视频播放</h5> <div class="ibox-tools"> <a class="collapse-link"> <i class="fa fa-chevron-up"></i> </a> <a class="dropdown-toggle" data-toggle="dropdown" href="form_basic.html#"> <i class="fa fa-wrench"></i> </a> <a class="close-link"> <i class="fa fa-times"></i> </a> </div> </div> <div class="ibox-content"> <div class="player"> <video src=""> <!-- Video files --> Your browser does not support the video tag. <source src="http://localhost:8080" type="video/mp4"> <a href="">Download</a> </video> </div> </div> </div> ``` 我该怎么去获取这个视频啊,,,,,,, 第一次写这个视频的上传与播放 求大佬指点。。。。。。。。
怎么解决R语言 安装gganimate的问题
devtools::install_github("dgrtwo/gganimate") Downloading GitHub repo dgrtwo/gganimate@master from URL https://api.github.com/repos/dgrtwo/gganimate/zipball/master Installing gganimate Downloading GitHub repo thomasp85/tweenr@master from URL https://api.github.com/repos/thomasp85/tweenr/zipball/master WARNING: Rtools is required to build R packages, but no version of Rtools compatible with R 3.5.0 was found. (Only the following incompatible version(s) of Rtools were found:3.5) Please download and install the appropriate version of Rtools from http://cran.r-project.org/bin/windows/Rtools/. Installing tweenr "C:/PROGRA~1/R/R-35~1.0/bin/x64/R" \ --no-site-file --no-environ --no-save \ --no-restore --quiet CMD INSTALL \ "C:/Users/zhangchen/AppData/Local/Temp/RtmpmYA2xF/devtools6f06713a6/thomasp85-tweenr-dc60be6" \ --library="C:/Users/zhangchen/Documents/R/win-library/3.5" \ --install-tests * installing *source* package 'tweenr' ... ** libs *** arch - i386 Warning in system(cmd) : 'make' not found ERROR: compilation failed for package 'tweenr' * removing 'C:/Users/zhangchen/Documents/R/win-library/3.5/tweenr' In R CMD INSTALL Installation failed: Command failed (1) "C:/PROGRA~1/R/R-35~1.0/bin/x64/R" \ --no-site-file --no-environ --no-save \ --no-restore --quiet CMD INSTALL \ "C:/Users/zhangchen/AppData/Local/Temp/RtmpmYA2xF/devtools6f015932143/thomasp85-gganimate-392819e" \ --library="C:/Users/zhangchen/Documents/R/win-library/3.5" \ --install-tests ERROR: dependency 'tweenr' is not available for package 'gganimate' * removing 'C:/Users/zhangchen/Documents/R/win-library/3.5/gganimate' In R CMD INSTALL Installation failed: Command failed (1) 安装之后一直报错,快崩溃了,哪位大神帮忙看下??
最近windowsServer2008服务器总是报错重启,有没有大神能帮忙分析下dmp文件?
Microsoft (R) Windows Debugger Version 6.8.0004.0 X86 Copyright (c) Microsoft Corporation. All rights reserved. Loading Dump File [C:\Users\Administrator\Desktop\103119-9750-01.dmp] Mini Kernel Dump File: Only registers and stack trace are available Symbol search path is: SRV*C:\Symbols*http://msdl.microsoft.com/download/symbols Executable search path is: Windows Kernel Version 7601 (Service Pack 1) MP (8 procs) Free x64 Product: Server, suite: Enterprise TerminalServer SingleUserTS Built by: 7601.17514.amd64fre.win7sp1_rtm.101119-1850 Kernel base = 0xfffff800`0161e000 PsLoadedModuleList = 0xfffff800`01863e90 Debug session time: Thu Oct 31 20:30:40.829 2019 (GMT+8) System Uptime: 0 days 9:27:14.453 Loading Kernel Symbols ........................................................................................................................................... Loading User Symbols Loading unloaded module list ........ ******************************************************************************* * * * Bugcheck Analysis * * * ******************************************************************************* Use !analyze -v to get detailed debugging information. BugCheck 18, {0, fffffa800acb5070, 2, ffffffffffdff100} Probably caused by : Unknown_Image ( ANALYSIS_INCONCLUSIVE ) Followup: MachineOwner --------- 0: kd> !analyze -v ******************************************************************************* * * * Bugcheck Analysis * * * ******************************************************************************* REFERENCE_BY_POINTER (18) Arguments: Arg1: 0000000000000000, Object type of the object whose reference count is being lowered Arg2: fffffa800acb5070, Object whose reference count is being lowered Arg3: 0000000000000002, Reserved Arg4: ffffffffffdff100, Reserved The reference count of an object is illegal for the current state of the object. Each time a driver uses a pointer to an object the driver calls a kernel routine to increment the reference count of the object. When the driver is done with the pointer the driver calls another kernel routine to decrement the reference count. Drivers must match calls to the increment and decrement routines. This bugcheck can occur because an object's reference count goes to zero while there are still open handles to the object, in which case the fourth parameter indicates the number of opened handles. It may also occur when the object’s reference count drops below zero whether or not there are open handles to the object, and in that case the fourth parameter contains the actual value of the pointer references count. Debugging Details: ------------------ CUSTOMER_CRASH_COUNT: 1 DEFAULT_BUCKET_ID: DRIVER_FAULT_SERVER_MINIDUMP BUGCHECK_STR: 0x18 PROCESS_NAME: svchost.exe CURRENT_IRQL: 0 LAST_CONTROL_TRANSFER: from 0000000000000000 to 0000000000000000 STACK_TEXT: 00000000`00000000 00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : 0x0 STACK_COMMAND: kb SYMBOL_NAME: ANALYSIS_INCONCLUSIVE FOLLOWUP_NAME: MachineOwner MODULE_NAME: Unknown_Module IMAGE_NAME: Unknown_Image DEBUG_FLR_IMAGE_TIMESTAMP: 0 BUCKET_ID: INVALID_KERNEL_CONTEXT Followup: MachineOwner ---------
【请教一个Nodejs问题】初学,要交作业了/SAD 大神们快进来看看
请问在不用express模块的情况下如何实现在页面上下载zip文件的功能呀?想用readFile先读取但是没有反应,也没有返回错误?是只能实现读图么?多谢。 详细信息: 我的作业是需要制作一个能登陆上传作业zip重命名并下载之前上传的zip的功能 现在做到了最后一步,下载zip 但是现在不清楚要如何操作 我百度了很多方法都是用express模块 但是因为之前老师没有讲过这么模块自己看不太懂 求大神指教!! 现在有四个文件 index.js server.js router.js requestHandlers.js requestHandlers.js 里有 function download(response,request){ console.log("准备点击下载"); fs.readFile("../homework/201512100103_阿丁呀.zip", function (err, file) { if (err) { throw err; } else { response.writeHead(200, {"Content-Type": "text/plain"}); response.write(file); response.end(); } }); } 就最后这个下载功能不会,求助!!
写了个java多线程下载器,但只有文件的部分内容下载成功。求大神!
import java.net.*; import java.io.*; class Test { //定义文件大小 private static int fileLength; //定义文件保存路径 private static String fileDirection; //定义线程数量 private static int threadNum; //定义线程组 private static Threads[] threads; //定义资源下载路径 private static String webDirection; /** * 默认构造器 * */ public Test(){} /** * 构造器: * 初始化threadNum(线程数量),fileDirection(文件保存路径),webDirection(资源下载路径) * */ public Test(int threadNum, String fileDirection, String webDirection) { this.threadNum = threadNum; this.fileDirection = fileDirection; this.webDirection = webDirection; //初始化threads数量。 threads = new Threads[threadNum]; } public static void downLoad() throws Exception { URL url = new URL(webDirection); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Accept", "*/*"); conn.setRequestProperty("Accept", "image/gif, image/jpeg, image/pjpeg, image/pjpeg, " + "application/x-shockwave-flash, application/xaml+xml, " + "application/vnd.ms-xpsdocument, application/x-ms-xbap, " + "application/x-ms-application, application/vnd.ms-excel, " + "application/vnd.ms-powerpoint, application/msword, */*"); conn.setRequestProperty("Charset", "UTF-8"); //获取连接 conn.connect(); //输出连接响应代码 System.out.println(conn.getResponseCode()); //获得文件大小 fileLength = conn.getContentLength(); //关闭连接 conn.disconnect(); //设置每条线程下载部分的大小 int subLength = fileLength / threadNum + 1; //设置本地文件的大小 RandomAccessFile file = new RandomAccessFile(fileDirection, "rw"); file.setLength(fileLength); file.close(); //以循环的方式来开始每一条线程 for (int i = 0; i < threadNum; i++) { //计算每条线程的下载的开始位置 int startPoint = i * subLength; //每条线程使用一个RandomAccessFile进行下载 RandomAccessFile subFile = new RandomAccessFile(fileDirection, "rw"); //定位该线程的下载位置 subFile.seek(startPoint); //初始化该线程 threads[i] = new Threads(subLength, startPoint, subFile, webDirection); //启动线程 threads[i].start(); } } } class Threads extends Thread { //定义该线程的下载位置 private static int startPoint; //当前线程需要下载的文件块 private static RandomAccessFile subFile; //定义资源的下载路径 private static String webDirection; //定义当前线程需要下载的问文件大小 private static int subLength; //定义已下载文件字节数 private static int length; /** * 构造器: * 初始化sublength,startPoint,subFile,webDirection * */ public Threads(int sublength, int startPoint, RandomAccessFile subFile, String webDirection) { this.startPoint = startPoint; this.subLength = sublength; this.subFile = subFile; this.webDirection = webDirection; } @Override public void run() { try { URL url = new URL(webDirection); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setConnectTimeout(1000); conn.setRequestProperty("Accept", "image/gif, image/jpeg, image/pjpeg, image/pjpeg, " + "application/x-shockwave-flash, application/xaml+xml, " + "application/vnd.ms-xpsdocument, application/x-ms-xbap, " + "application/x-ms-application, application/vnd.ms-excel, " + "application/vnd.ms-powerpoint, application/msword, */*"); conn.setRequestProperty("Accept-Language", "zh-CN"); conn.setRequestProperty("Charset", "UTF-8"); conn.connect(); //获取一个输出流, InputStream input = conn.getInputStream(); //是输出流跳过startpoint字节,表明该线程只下载自己负责的那一部分文件块 input.skip(startPoint); byte[] buffer = new byte[1024]; int hasNext = 0; //读取网络数据,并写入本地文件 while (length < subLength && (hasNext = input.read(buffer)) != -1) { subFile.write(buffer, 0, hasNext); //累计该线程的下载的总大小 length += hasNext; } input.close(); subFile.close(); } catch (Exception e) { } } } public class ThreadsDownload { public static void main(String[] args)throws Exception { // TODO Auto-generated method stub Test test = new Test(2, "C:\\Users\\Administrator\\Desktop\\music.txt", "http://shcm09.baidupcs.com/file/59980bec5eb499787dc6888f8c769620?bkt=p3-140059980bec5eb499787dc6888f8c769620847e32380000000003bc&fid=2283488641-250528-388951467231009&time=1484371050&sign=FDTAXGERLBH-DCb740ccc5511e5e8fedcff06b081203-%2FRxhx4PSo2A2tg6emD0bGTEM5DQ%3D&to=sh09vb&fm=Nan,B,M,mn&sta_dx=956&sta_cs=5&sta_ft=txt&sta_ct=0&sta_mt=0&fm2=Nanjing02,B,M,mn&newver=1&newfm=1&secfm=1&flow_ver=3&pkey=140059980bec5eb499787dc6888f8c769620847e32380000000003bc&sl=69926991&expires=8h&rt=pr&r=745301334&mlogid=314351329813847523&vuk=2283488641&vbdid=2298463801&fin=test.txt&fn=test.txt&slt=pm&uta=0&rtype=1&iv=0&isw=0&dp-logid=314351329813847523&dp-callid=0.1.1&csl=500&csign=Cfc%2B%2Bn4hgLFC3dLFpSY0MMKwS%2BE%3D"); test.downLoad(); }
suse12sp2:如何安装docker-1.12.1?
各位大神好: 作为一个docker的小白,我想在一台suse:sles:12:sp2上安装docker-1.12.1。 OS信息如下: mo-887de210b:/data # cat /etc/os-release NAME="SLES" VERSION="12-SP2" VERSION_ID="12.2" PRETTY_NAME="SUSE Linux Enterprise Server 12 SP2" ID="sles" ANSI_COLOR="0;32" CPE_NAME="cpe:/o:suse:sles:12:sp2" 安装的具体步骤如下: ============================= 好像没有现成的包,要自己去download下来装 install docker on suse 12.1 1.             download:  https://software.opensuse.org/package/docker  (containerd 0.2.3)   2.             zypper in containerd-0.2.3+git4f0a33a-25.1.x86_64.rpm   3.             zypper in docker-1.12.1-146.1.x86_64.rpm   4.          zypper runc-1.0_dev+git10da74a-23.1.x86_64.rpm   5.             systemctl start docker; systemctl status docker   6.             docker -v   7.             docker info  但是我却在第一步安装containerd-0.2.3时就遭遇了失败:( ==================== containerd-0.2.3+git4f0a33a-25.1.x86_64 (Plain RPM files cache): **Signature verification failed [4-Signatures public key is not available]** 哪位大神可以指导一二? 万分感谢!! 具体错误信息如下: ============= mo-887de210b:/data/docker # zypper in containerd-0.2.3+git4f0a33a-25.1.x86_64.rpm Loading repository data... Reading installed packages... Resolving package dependencies... The following NEW package is going to be installed: containerd The following package is not supported by its vendor: containerd 1 new package to install. Overall download size: 2.4 MiB. Already cached: 0 B. After the operation, additional 12.2 MiB will be used. Continue? [y/n/...? shows all options] (y): y Retrieving package containerd-0.2.3+git4f0a33a-25.1.x86_64 (1/1), 2.4 MiB ( 12.2 MiB unpacked) containerd-0.2.3+git4f0a33a-25.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 72174fc2: NOKEY V3 RSA/SHA256 Signature, key ID 72174fc2: NOKEY containerd-0.2.3+git4f0a33a-25.1.x86_64 (Plain RPM files cache): **Signature verification failed [4-Signatures public key is not available]** Abort, retry, ignore? [a/r/i] (a): i Checking for file conflicts: .................................................................................................................................[done] (1/1) Installing: containerd-0.2.3+git4f0a33a-25.1.x86_64 ....................................................................................................[done] Additional rpm output: warning: /var/tmp/zypp.ZA7LFu/zypper/containerd-0.2.3+git4f0a33a-25.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 72174fc2: NOKEY Updating /etc/sysconfig/containerd… mo-887de210b:/data/docker # zypper in docker-1.12.1-146.1.x86_64.rpm Loading repository data... Reading installed packages... Resolving package dependencies...   Problem: **nothing provides containerd = 0.2.3 needed by docker-1.12.1**-146.1.x86_64  Solution 1: do not install docker-1.12.1-146.1.x86_64  Solution 2: break docker-1.12.1-146.1.x86_64 by ignoring some of its dependencies   Choose from above solutions by number or cancel [1/2/c] (c): c
获取的图片地址乱码解决,但是保存的图片乱码怎么解决?在线等,求大神,解决,速结贴
package com.togest.emis.modules.resource.web; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.codec.binary.Base64; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import com.togest.emis.framework.utils.EncodeUtils; /** * * * @author mmk * */ @Controller public class PsaveController { @RequestMapping(value="save",method = RequestMethod.POST) public void save(Map<String,Object> map,HttpServletRequest request,HttpServletResponse response) throws IOException{ String imageData2 = request.getParameter("imageData2"); String file_path = request.getParameter("file_path"); file_path = URLDecoder.decode(file_path , "utf-8"); System.out.println("++++++++++++++++"+file_path); //String f = new String(request.getParameter("file_path").getBytes("ISO-8859-1"),"UTF-8"); //System.out.println("+++++++++++++++++"+f); String file_name = request.getParameter("file_name"); String Path = request.getSession().getServletContext().getRealPath("/"); String filePath2 = file_path.substring(0, 34); String filePath=file_path.replace(filePath2,Path); filePath =EncodeUtils.isoDecode(filePath); String fileName=file_name; File file = new File(filePath); System.out.println("+++++++"+filePath); //System.out.println("+++++++++"+EncodeUtils.isoDecode(filePath)); if(imageData2!=null){ try{ FileOutputStream write = new FileOutputStream(file); byte[] decoderBytes = Base64.decodeBase64(imageData2.replace("data:image/png;base64,","")); imageData2 = imageData2.replace("base64,",""); write.write(decoderBytes); write.flush(); write.close(); }catch(Exception e){ e.printStackTrace(); } } } } 保存控制器代码 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ include file="/common/taglibs.jsp"%> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title></title> <!-- jQuery --> <script type="text/javascript" src="${pageContext.request.contextPath}/system/js/jquery-1.8.2.min.js"></script> <script type="text/javascript" src="${pageContext.request.contextPath}/system/js/jquery.ui.core.min.js"></script> <script type="text/javascript" src="${pageContext.request.contextPath}/system/js/jquery.ui.widget.min.js"></script> <script type="text/javascript" src="${pageContext.request.contextPath}/system/js/jquery.ui.mouse.min.js"></script> <script type="text/javascript" src="${pageContext.request.contextPath}/system/js/jquery.ui.draggable.min.js"></script> <script type="text/javascript" src="${pageContext.request.contextPath}/system/js/jquery.base64.js"></script> <!-- wColorPicker --> <link rel="Stylesheet" type="text/css" href="${pageContext.request.contextPath}/system/css/wColorPicker.css" /> <script type="text/javascript" src="${pageContext.request.contextPath}/system/js/wColorPicker.js"></script> <!-- wPaint --> <link rel="Stylesheet" type="text/css" href="${pageContext.request.contextPath}/system/css/wPaint.css" /> <script type="text/javascript" src="${pageContext.request.contextPath}/system/js/wPaint.js"></script> </head> <body> <!-- <img id="canvasImage3" onload="DrawImage(this)" style="display:none" src="${requestScope.filePath}" name="${requestScope.fileName}" />--> <img id="canvasImage3" onload="DrawImage(this)" style="display:none" /> <table id="full"> <tr> <td> <div id="wPaint2" style="position:relative; width:1620px;height:1200px;background:#CACACA; border:solid black 1px;"> </div> </td> <!-- <td><img id="canvasImage2" src=""/></td>--> </tr> <tr> <td colspan="2"> <div> <div id="box"></div> <input type="button" value="保存" onClick="saveImage2()" onblur="saveImage2()" /> <input type="button" value="提交" onblur="saveImage2()" onclick="saveImage2()"> <input type="button" value="全屏" onclick="full_screen()"> </div> <br /> </td> </tr> </table> <br /> <br /> <script type="text/javascript"> $(document).ready(function() { //alert('${filePath}'); ///alert('${ctx}/fileupload/download_file_url?fileDir=${filePath}'); $('#canvasImage3').attr('src','${ctx}/fileupload/download_file_url?fileDir=${filePath}'); }); function saveImage2() { var imageData2 = $("#wPaint2").wPaint("image");//获取wPaint的image属性值可获取base64格式的图片数据 var file_path = encodeURI(document.getElementById("canvasImage3").src);//这个获取乱码 file_path = encodeURI(file_path); var file_name = document.getElementById("canvasImage3").name; alert(file_path); $.ajax({ url : '${ctx}/save', type : 'post', data : { imageData2 : imageData2, file_path : file_path, file_name : file_name }, dataType : "json", success : function(result) { alert(result); if ("ture" == $.trim(result)) { $("#box").html("保存成功"); } else { $("#box").html("保存失败"); } }, error : function() { $("#box").html("保存成功"); } }); //$("#canvasImage2").attr('src', imageData2); } function convertCanvasToImage(canvas) { var image = new Image(); image.src = canvas.toDataURL("image/png"); return image; } var flag = false; //控制小图 function DrawImage(ImgD) { var image = new Image(); image.src = ImgD.src; if (image.width > 1620 || image.height > 1200) { image.width = 1620; image.height = 1200; } $("#wPaint2").css({ width : image.width, height : image.height }); $("#wPaint2").wPaint({ menuOrientation : 'vertical', imageBg : image.src }); } function full_screen() { var full = document.getElementById("full"); requestFullScreen(full); } function requestFullScreen(element) { var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen; if (requestMethod) { requestMethod.call(element); } else if (typeof window.ActiveXObject !== "undefined") { var wscript = new ActiveXObject("WScript.Shell"); if (wscript !== null) { wscript.SendKeys("{F11}"); } } } </script> </body> </html> 编辑页面如下
文件下载,下载的不是目标文件而是整个页面
跪求各位大神指点一下,采用下面这个函数实现下载文件功能时,下载的不是目标文件,而是整个页面... class Download { private $file; public function __construct($file)//$file为从数据库中获取到的文件相对存储地址 { $this->file=$file; $this->downloads($this->file); } public function downloads($file) { $file=iconv("utf-8","gb2312",$file); $file_dir = $_SERVER['__SELF__']."Uploads".$file; //echo $file_dir; $filename=pathinfo($file); if (!file_exists($file_dir)) { echo "文件已被删除!!"; exit(); } else { $file = fopen($file_dir,"r"); header("Content-Type: application/octet-stream"); header("Accept-Ranges: bytes"); header("Accept-Length: ".filesize($file_dir)); header("Content-Disposition: attachment; filename=".$filename["basename"]); ob_clean(); flush(); readfile($file, filesize($file_dir)); fclose($file); } } }
动态规划入门到熟悉,看不懂来打我啊
持续更新。。。。。。 2.1斐波那契系列问题 2.2矩阵系列问题 2.3跳跃系列问题 3.1 01背包 3.2 完全背包 3.3多重背包 3.4 一些变形选讲 2.1斐波那契系列问题 在数学上,斐波纳契数列以如下被以递归的方法定义:F(0)=0,F(1)=1, F(n)=F(n-1)+F(n-2)(n&gt;=2,n∈N*)根据定义,前十项为1, 1, 2, 3...
130 个相见恨晚的超实用网站,一次性分享出来
相见恨晚的超实用网站 持续更新中。。。
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
Python——画一棵漂亮的樱花树(不同种樱花+玫瑰+圣诞树喔)
最近翻到一篇知乎,上面有不少用Python(大多是turtle库)绘制的树图,感觉很漂亮,我整理了一下,挑了一些我觉得不错的代码分享给大家(这些我都测试过,确实可以生成) one 樱花树 动态生成樱花 效果图(这个是动态的): 实现代码 import turtle as T import random import time # 画樱花的躯干(60,t) def Tree(branch, ...
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看...
我在支付宝花了1分钟,查到了女朋友的开房记录!
在大数据时代下,不管你做什么都会留下蛛丝马迹,只要学会把各种软件运用到极致,捉奸简直轻而易举。今天就来给大家分享一下,什么叫大数据抓出轨。据史料证明,马爸爸年轻时曾被...
shell脚本:备份数据库、代码上线
备份MySQL数据库 场景: 一台MySQL服务器,跑着5个数据库,在没有做主从的情况下,需要对这5个库进行备份 需求: 1)每天备份一次,需要备份所有的库 2)把备份数据存放到/data/backup/下 3)备份文件名称格式示例:dbname-2019-11-23.sql 4)需要对1天以前的所有sql文件压缩,格式为gzip 5)本地数据保留1周 6)需要把备份的数据同步到远程备份中心,假如...
聊聊C语言和指针的本质
坐着绿皮车上海到杭州,24块钱,很宽敞,在火车上非正式地聊几句。 很多编程语言都以 “没有指针” 作为自己的优势来宣传,然而,对于C语言,指针却是与生俱来的。 那么,什么是指针,为什么大家都想避开指针。 很简单, 指针就是地址,当一个地址作为一个变量存在时,它就被叫做指针,该变量的类型,自然就是指针类型。 指针的作用就是,给出一个指针,取出该指针指向地址处的值。为了理解本质,我们从计算机模型说起...
为什么你学不过动态规划?告别动态规划,谈谈我的经验
动态规划难吗?说实话,我觉得很难,特别是对于初学者来说,我当时入门动态规划的时候,是看 0-1 背包问题,当时真的是一脸懵逼。后来,我遇到动态规划的题,看的懂答案,但就是自己不会做,不知道怎么下手。就像做递归的题,看的懂答案,但下不了手,关于递归的,我之前也写过一篇套路的文章,如果对递归不大懂的,强烈建议看一看:为什么你学不会递归,告别递归,谈谈我的经验 对于动态规划,春招秋招时好多题都会用到动态...
程序员一般通过什么途径接私活?
二哥,你好,我想知道一般程序猿都如何接私活,我也想接,能告诉我一些方法吗? 上面是一个读者“烦不烦”问我的一个问题。其实不止是“烦不烦”,还有很多读者问过我类似这样的问题。 我接的私活不算多,挣到的钱也没有多少,加起来不到 20W。说实话,这个数目说出来我是有点心虚的,毕竟太少了,大家轻喷。但我想,恰好配得上“一般程序员”这个称号啊。毕竟苍蝇再小也是肉,我也算是有经验的人了。 唾弃接私活、做外...
字节跳动面试官这样问消息队列:分布式事务、重复消费、顺序消费,我整理了一下
你知道的越多,你不知道的越多 点赞再看,养成习惯 GitHub上已经开源 https://github.com/JavaFamily 有一线大厂面试点脑图、个人联系方式和人才交流群,欢迎Star和完善 前言 消息队列在互联网技术存储方面使用如此广泛,几乎所有的后端技术面试官都要在消息队列的使用和原理方面对小伙伴们进行360°的刁难。 作为一个在互联网公司面一次拿一次Offer的面霸...
2020年大前端发展趋势
迅速发展的前端开发,在每⼀年,都为开发者带来了新的关键词。2019 年已步⼊尾声,2020 年前端发展的关键词⼜将有哪些呢?发展的方向又会是什么呢?参考2019年大前端的发展,不出意外,前端依旧会围绕⼩程序、超级APP、跨端开发、前端⼯程化以及新技术运用等几个方面进行展开(可以参考2019年大前端技术趋势深度解读)。 小程序 在⼩程序⽅⾯,今年仍然是⼩程序突⻜猛进的⼀年,各⼤主流的 App 都上线...
如何安装 IntelliJ IDEA 最新版本——详细教程
IntelliJ IDEA 简称 IDEA,被业界公认为最好的 Java 集成开发工具,尤其在智能代码助手、代码自动提示、代码重构、代码版本管理(Git、SVN、Maven)、单元测试、代码分析等方面有着亮眼的发挥。IDEA 产于捷克,开发人员以严谨著称的东欧程序员为主。IDEA 分为社区版和付费版两个版本。 我呢,一直是 Eclipse 的忠实粉丝,差不多十年的老用户了。很早就接触到了 IDEA...
1个月时间整理了2019年上千道Java面试题,近500页文档!
Spring 面试题 1、一般问题 1.1、不同版本的 spring Framework 有哪些主要功能? 1.2、什么是 spring Framework? 1.3、列举 spring Framework 的优点。 1.4、spring Framework 有哪些不同的功能? 1.5、spring Framework 中有多少个模块,它们分别是什么? 1.6、什么是 spring ...
面试还搞不懂redis,快看看这40道面试题(含答案和思维导图)
Redis 面试题 1、什么是 Redis?. 2、Redis 的数据类型? 3、使用 Redis 有哪些好处? 4、Redis 相比 Memcached 有哪些优势? 5、Memcache 与 Redis 的区别都有哪些? 6、Redis 是单进程单线程的? 7、一个字符串类型的值能存储最大容量是多少? 8、Redis 的持久化机制是什么?各自的优缺点? 9、Redis 常见性...
为什么要推荐大家学习字节码?
配套视频: 为什么推荐大家学习Java字节码 https://www.bilibili.com/video/av77600176/ 一、背景 本文主要探讨:为什么要学习 JVM 字节码? 可能很多人会觉得没必要,因为平时开发用不到,而且不学这个也没耽误学习。 但是这里分享一点感悟,即人总是根据自己已经掌握的知识和技能来解决问题的。 这里有个悖论,有时候你觉得有些技术没用恰恰是...
在阿里,40岁的奋斗姿势
在阿里,40岁的奋斗姿势 在阿里,什么样的年纪可以称为老呢?35岁? 在云网络,有这样一群人,他们的平均年龄接近40,却刚刚开辟职业生涯的第二战场。 他们的奋斗姿势是什么样的呢? 洛神赋 “翩若惊鸿,婉若游龙。荣曜秋菊,华茂春松。髣髴兮若轻云之蔽月,飘飖兮若流风之回雪。远而望之,皎若太阳升朝霞;迫而察之,灼若芙蕖出渌波。” 爱洛神,爱阿里云 2018年,阿里云网络产品部门启动洛神2.0升...
【超详细分析】关于三次握手与四次挥手面试官想考我们什么?
在面试中,三次握手和四次挥手可以说是问的最频繁的一个知识点了,我相信大家也都看过很多关于三次握手与四次挥手的文章,今天的这篇文章,重点是围绕着面试,我们应该掌握哪些比较重要的点,哪些是比较被面试官给问到的,我觉得如果你能把我下面列举的一些点都记住、理解,我想就差不多了。 三次握手 当面试官问你为什么需要有三次握手、三次握手的作用、讲讲三次三次握手的时候,我想很多人会这样回答: 首先很多人会先讲下握...
压测学习总结(1)——高并发性能指标:QPS、TPS、RT、吞吐量详解
一、QPS,每秒查询 QPS:Queries Per Second意思是“每秒查询率”,是一台服务器每秒能够相应的查询次数,是对一个特定的查询服务器在规定时间内所处理流量多少的衡量标准。互联网中,作为域名系统服务器的机器的性能经常用每秒查询率来衡量。 二、TPS,每秒事务 TPS:是TransactionsPerSecond的缩写,也就是事务数/秒。它是软件测试结果的测量单位。一个事务是指一...
新程序员七宗罪
当我发表这篇文章《为什么每个工程师都应该开始考虑开发中的分析和编程技能呢?》时,我从未想到它会对读者产生如此积极的影响。那些想要开始探索编程和数据科学领域的人向我寻求建议;还有一些人问我下一篇文章的发布日期;还有许多人询问如何顺利过渡到这个职业。我非常鼓励大家继续分享我在这个旅程的经验,学习,成功和失败,以帮助尽可能多的人过渡到一个充满无数好处和机会的职业生涯。亲爱的读者,谢谢你。 -罗伯特。 ...
活到老,学到老,程序员也该如此
全文共2763字,预计学习时长8分钟 图片来源:Pixabay 此前,“网传阿里巴巴要求尽快实现P8全员35周岁以内”的消息闹得沸沸扬扬。虽然很快被阿里辟谣,但苍蝇不叮无缝的蛋,无蜜不招彩蝶蜂。消息从何而来?真相究竟怎样?我们无从而知。我们只知道一个事实:不知从何时开始,程序猿也被划在了“吃青春饭”行业之列。 饱受“996ICU”摧残后,好不容易“头秃了变强了”,即将步入为“高...
Vue快速实现通用表单验证
本文开篇第一句话,想引用鲁迅先生《祝福》里的一句话,那便是:“我真傻,真的,我单单知道后端整天都是CRUD,我没想到前端整天都是Form表单”。这句话要从哪里说起呢?大概要从最近半个月的“全栈工程师”说起。项目上需要做一个城市配载的功能,顾名思义,就是通过框选和拖拽的方式在地图上完成配载。博主选择了前后端分离的方式,在这个过程中发现:首先,只要有依赖jQuery的组件,譬如Kendoui,即使使用...
2019年Spring Boot面试都问了什么?快看看这22道面试题!
Spring Boot 面试题 1、什么是 Spring Boot? 2、Spring Boot 有哪些优点? 3、什么是 JavaConfig? 4、如何重新加载 Spring Boot 上的更改,而无需重新启动服务器? 5、Spring Boot 中的监视器是什么? 6、如何在 Spring Boot 中禁用 Actuator 端点安全性? 7、如何在自定义端口上运行 Sprin...
Unity项目在pc和ios设备上黑屏的原因探究
0x00 由于项目上线了windows平台的项目(别问我为什么,咱也不敢说,咱也不敢问),由Unity5.4.6升级到Unity2018的过程中,遇到了各种各样的坑,本文为避坑指南1。本项目没有使用HDR和抗锯齿,由于查这几个问题查到吐血,前后用了3天的时间,本文充满了怨气,行文非常啰嗦,需要快速解决问题的,可以直接拉到最后看结论。 0x01 法线贴图 项目在unity2018出了新的androi...
关于裁员几点看法及建议
最近网易裁员事件引起广泛关注,昨天网易针对此事,也发了声明,到底谁对谁错,孰是孰非?我们作为吃瓜观众实在是知之甚少,所以不敢妄下定论。身处软件开发这个行业,近一两年来,对...
面试官:关于Java性能优化,你有什么技巧
通过使用一些辅助性工具来找到程序中的瓶颈,然后就可以对瓶颈部分的代码进行优化。 一般有两种方案:即优化代码或更改设计方法。我们一般会选择后者,因为不去调用以下代码要比调用一些优化的代码更能提高程序的性能。而一个设计良好的程序能够精简代码,从而提高性能。 下面将提供一些在JAVA程序的设计和编码中,为了能够提高JAVA程序的性能,而经常采用的一些方法和技巧。 1.对象的生成和大小的调整。 J...
【图解算法面试】记一次面试:说说游戏中的敏感词过滤是如何实现的?
版权声明:本文为苦逼的码农原创。未经同意禁止任何形式转载,特别是那些复制粘贴到别的平台的,否则,必定追究。欢迎大家多多转发,谢谢。 小秋今天去面试了,面试官问了一个与敏感词过滤算法相关的问题,然而小秋对敏感词过滤算法一点也没听说过。于是,有了下下事情的发生… 面试官开怼 面试官:玩过王者荣耀吧?了解过敏感词过滤吗?,例如在游戏里,如果我们发送“你在干嘛?麻痹演员啊你?”,由于“麻痹”是一个敏感词,...
相关热词 c# 数组类型 泛型约束 c#的赛狗日程序 c# 传递数组 可变参数 c# 生成存储过程 c# list 补集 c#获得所有窗体 c# 当前秒数转成年月日 c#中的枚举 c# 计算校验和 连续随机数不重复c#
立即提问