当前位置: 首页 > news >正文

网站漂浮广告怎么做网站开发工程师英文简历

网站漂浮广告怎么做,网站开发工程师英文简历,长沙seo优化推荐,管理评价一般通过服务类 系统盘符:file-path.disk(可能会变,配置配置文件dev中)文件根路径:file-path.root-path(可能会变,配置配置文件dev中)http协议的Nginx的映射前缀:PrefixConstant.…

服务类

  • 系统盘符:file-path.disk(可能会变,配置配置文件dev中)
  • 文件根路径:file-path.root-path(可能会变,配置配置文件dev中)
  • http协议的Nginx的映射前缀:PrefixConstant.HTTP_PREFIX
package com.sky.service;import com.sky.constant.MessageConstant;
import com.sky.constant.PrefixConstant;
import com.sky.exception.BaseException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;import java.io.File;
import java.io.IOException;@Service
public class CommonService {@Value("${file-path.disk}")private String disk;@Value("${file-path.root-path}")private String rootPath;/*** 文件上传** @param parentPath 父路径* @param file       文件*/public String upload(String parentPath, MultipartFile file) {// Upload fileString fileName = file.getOriginalFilename();// Get full path using system file separatorString fullPath = disk + ":" + File.separator + rootPath + File.separator + parentPath;// Create the directory if it doesn't existFile directory = new File(fullPath);if (!directory.exists()) {directory.mkdirs();}// Create the destination fileFile dest = new File(directory, fileName);try {file.transferTo(dest);} catch (IOException e) {throw new BaseException(MessageConstant.UPLOAD_FAILED);}// Return the file access URLreturn PrefixConstant.HTTP_PREFIX +fileName;}
}

配置文件

在这里插入图片描述

总配置文件

sky:jwt:# 设置jwt签名加密时使用的秘钥admin-secret-key: itcast# 设置jwt过期时间admin-ttl: 720000000# 设置前端传递过来的令牌名称admin-token-name: tokenfile-path:disk: ${file-path.disk}root-path: ${file-path.root-path}

开发环境配置文件

file-path:disk: Droot-path: sky_take_out

常量类

在这里插入图片描述

文件路径常量

package com.sky.constant;public class SystemPathConstant {public static final String COMMON = "common";// 构造函数私有化private SystemPathConstant() {}
}

nginx路径映射常量

package com.sky.constant;public class PrefixConstant {public static final String HTTP_PREFIX = "http://localhost/files/";// 构造函数私有化private PrefixConstant() {}
}

controller层

别人上传完图片之后把访问路径给别人(http的路径,不是本地路径)

    @PostMapping("/upload")@ApiOperation("文件上传")public Result<String> upload(MultipartFile file) {log.info("文件上传:{}", file);// 将文件上传到本地文件夹下// 返回文件的访问路径String filePath = commonService.upload(SystemPathConstant.COMMON,file);return Result.success(filePath);}

配置类放行静态资源

package com.sky.config;import com.sky.constant.SystemPathConstant;
import com.sky.interceptor.JwtTokenAdminInterceptor;
import com.sky.json.JacksonObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;import java.util.List;/*** 配置类,注册web层相关组件*/
@Configuration
@Slf4j
public class WebMvcConfiguration extends WebMvcConfigurationSupport {@Autowiredprivate JwtTokenAdminInterceptor jwtTokenAdminInterceptor;@Value("${file-path.disk}")private String disk;@Value("${file-path.root-path}")private String rootPath;..... 其他配置一万行/*** 设置静态资源映射* @param registry*/protected void addResourceHandlers(ResourceHandlerRegistry registry) {registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/");registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");// Map the file directory to a URL pathregistry.addResourceHandler("/files/**").addResourceLocations("file:" +disk + ":" + "/" +rootPath + "/" +SystemPathConstant.COMMON + "/");}}

nginx映射

静态资源到本地盘符(这就你的代码中配置的判读)

  • 这个文件是开发环境的,正式环境按照正式环境的路径和盘符配置
    改完记得重启一下
       location /files/ {alias D:/sky_take_out/common/;}
  • 有的时候会访问403 异常
  • 文件权限异常
  • 访问一定要访问具体文件,不要访问到文件夹
    在这里插入图片描述
http://www.yayakq.cn/news/717848/

相关文章:

  • 阜新市网站建设建设银行个人网上银行网站加载
  • 苏州做网站最好公司赣州酒店网站设计
  • 莆田系医院的网站用什么做的一对一软件
  • 网络营销 企业网站海外贸易在什么网站做
  • 关于网站建设的网站有哪些天河区网站公司
  • 中国企业网站建设外包服务市场手机网站开发session
  • 宜昌网站建设哪个公司好房地产网站做百度推广
  • 做网站如何把支付宝微信吧网站建设中 显示 虚拟机
  • 东平网站制作哪家好wordpress如何生成html
  • 做网站工具 不懂代码无锡网页建站
  • 摄影师网站模板成都自动seo
  • 食品网站制作建设企业网站的需求
  • 做阿里巴巴怎么进公司网站网站首页下拉广告
  • 宝安营销型网站制作网站建设的目录浏览
  • 权威的郑州网站建设外贸网站源码 php
  • 做封面的软件ps下载网站深圳代理记账公司电话
  • 网页设计网站结构图怎么弄秦皇岛优化网站排名
  • 企业网站推广方案网络营销作业wordpress仿卢松松
  • 学校门户网站模板python入门教程完整版
  • 南宁网站建设 超薄网络html个人网页设计代码
  • 商城购物网站建设方案服装网站公司网站
  • 关键词查询网站电脑网页怎么截图
  • 沭阳找做网站合伙中细软网站建设
  • 现在还用dw做网站设计么团购网站建站
  • 重庆云阳网站建设报价网站打开是目录结构图
  • 庆阳网站建设报价河南建设工程教育网
  • 做网站一屏有多大不知此网站枉做男人的网站
  • 网站开发教材绿植网站怎么做
  • 站长之家素材网如何注册免费网站域名
  • 企业网站哪家公司好网站建设属于会计哪个科目