1.Google页面显示"Not allowed to load local resource"
报错原因:谷歌浏览器禁止直接访问磁盘文件(估计是出于安全考虑,要不然的话通过浏览器就可以访问本地的东西确实有点危险)
使用了Tomcat的解决方法:
给tomcat配一个虚拟路径,tomcat本身会把这个虚拟路径解析为本地磁盘路径,这样既解决了访问不了图片的问题,有保证了浏览器只能访问指定文件夹。
步骤如下:
1、找到tomcat的配置文件(\conf\server.xml)并打开
2、在<host>与</host>之间加入如下代码:<Context path="/file" docBase="E:\test" debug="0" reloadable="true"/>】其中:path就是映射的路径,docBase就是你的文件所在路径
3、调用方法:【E:\test】下有一张test.jpg的图片
【img 标签中的src改为“/file/test.jpg”】
使用SpringBoot的解决方法,SpringBoot内置了Tomcat,故须在配置文件中修改。
这时候需要在application.properties里面加入如下。
#图片的位置
prop.upload-folder=C:/Users/Administrator/IdeaProjects/his_sprintboot/src/main/resources/static/uploadImg
spring.web.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,\
classpath:/static/,classpath:/public/,file:${prop.upload-folder}
前端的路径:路径使用文件名。
// 上传图片成功后的赋值信息
handleSuccess(res) {
this.preUrl= res.info.fileAddress
this.name=res.info.message
// this.fileListArray.push(preUrl)
// this.fileList.push({ url: preUrl })
this.picList.push(this.name)
this.fileList=this.picList.map(item=>{
return{
name:item,
url:this.name
}
})
2.链接Redis时出现 “ERR Client sent AUTH, but no password is set” 异常的原因及解决办法
原因:Redis服务器没有设置密码,但客户端向其发送了AUTH(authentication,身份验证)请求。
redis的命令行启动方式:redis-server.exe redis.windows.conf
使用的配置文件是redis.winndows.conf
在redis.windows.conf 文件,用文本编辑工具打开文件,找到“requirepass”,去掉注释设置密码。
将#requirepass foobared改为requirepass 密码。
问题成功解决。
在项目中的key值,CartPrefix:cart7,在命令行中得到时,出现:(error) NOAUTH Authentication required.
解决:输入auth 密码
3.gradle项目中出现:commandline is too long
Error running 'Application': Command line is too long. Shorten command line for Application or also for Spring Boot default configuration?
方法一:
把项目的.idea/workspace.xml打开,在component要素:PropertiesComponent 插入一下代码
<property name="dynamic.classpath" value="true" />
方法二:
在右上角选择edit configuration,在configuration中的Enviroment中Shorten commandline中选择JAR manifest