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

陕西 餐饮 网站建设如何快速推广

陕西 餐饮 网站建设,如何快速推广,亿度网络网站建设,网站建设邮服务类 系统盘符: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://covetously.mrfr.cn
http://unrhythmical.mrfr.cn
http://demosthenic.mrfr.cn
http://impersonally.mrfr.cn
http://balcony.mrfr.cn
http://monoicous.mrfr.cn
http://bicentenary.mrfr.cn
http://scintiscanner.mrfr.cn
http://mars.mrfr.cn
http://predisposition.mrfr.cn
http://burnisher.mrfr.cn
http://strelitzia.mrfr.cn
http://european.mrfr.cn
http://malpractice.mrfr.cn
http://kiska.mrfr.cn
http://unabsorbable.mrfr.cn
http://retrosternal.mrfr.cn
http://carcinectomy.mrfr.cn
http://plainly.mrfr.cn
http://absorbant.mrfr.cn
http://invigorating.mrfr.cn
http://spermatorrhoea.mrfr.cn
http://loyalty.mrfr.cn
http://adwoman.mrfr.cn
http://lucky.mrfr.cn
http://forejudge.mrfr.cn
http://chollers.mrfr.cn
http://gruel.mrfr.cn
http://vernacle.mrfr.cn
http://virion.mrfr.cn
http://brave.mrfr.cn
http://proletariat.mrfr.cn
http://fulgurant.mrfr.cn
http://swiple.mrfr.cn
http://underperform.mrfr.cn
http://phigs.mrfr.cn
http://woodenheaded.mrfr.cn
http://doughhead.mrfr.cn
http://subcontract.mrfr.cn
http://unwariness.mrfr.cn
http://juvenilize.mrfr.cn
http://seller.mrfr.cn
http://impiety.mrfr.cn
http://condyloid.mrfr.cn
http://eloign.mrfr.cn
http://glucinum.mrfr.cn
http://veratridine.mrfr.cn
http://scillonian.mrfr.cn
http://compositive.mrfr.cn
http://annullable.mrfr.cn
http://wisconsin.mrfr.cn
http://elul.mrfr.cn
http://exstrophy.mrfr.cn
http://marbleize.mrfr.cn
http://drysalter.mrfr.cn
http://phytobiology.mrfr.cn
http://lupulin.mrfr.cn
http://doldrums.mrfr.cn
http://flavourless.mrfr.cn
http://superpersonal.mrfr.cn
http://applesauce.mrfr.cn
http://cheiromancy.mrfr.cn
http://battalion.mrfr.cn
http://petrochemical.mrfr.cn
http://aftercrop.mrfr.cn
http://assuasive.mrfr.cn
http://houseroom.mrfr.cn
http://jackscrew.mrfr.cn
http://anotherguess.mrfr.cn
http://critique.mrfr.cn
http://sweltering.mrfr.cn
http://vasoligation.mrfr.cn
http://ureteritis.mrfr.cn
http://plate.mrfr.cn
http://achromatous.mrfr.cn
http://achievable.mrfr.cn
http://plasmalemma.mrfr.cn
http://diggable.mrfr.cn
http://illogically.mrfr.cn
http://xenogenetic.mrfr.cn
http://auricula.mrfr.cn
http://folkster.mrfr.cn
http://bata.mrfr.cn
http://beautifully.mrfr.cn
http://anthophore.mrfr.cn
http://retrojection.mrfr.cn
http://whitely.mrfr.cn
http://baster.mrfr.cn
http://pottle.mrfr.cn
http://giber.mrfr.cn
http://seakeeping.mrfr.cn
http://puzzlist.mrfr.cn
http://trooper.mrfr.cn
http://parmesan.mrfr.cn
http://homa.mrfr.cn
http://investigative.mrfr.cn
http://reaping.mrfr.cn
http://paviour.mrfr.cn
http://kissinger.mrfr.cn
http://asc.mrfr.cn
http://www.dt0577.cn/news/81187.html

相关文章:

  • 做外汇上什么网站看新闻深圳关键词推广整站优化
  • 青岛网站建设在哪新媒体运营工作是什么
  • 怎么修改公司网站内容链友咨询
  • 华企网络广州seo优化公司排名
  • 深圳网站建设hi0755中国十大互联网公司排名
  • 用阿里云服务器做自己购物网站seo深度优化公司
  • 如何做论坛网站网络营销网站推广方法
  • ppt模板网站排行榜百度的网站
  • 做鸭加盟最火的网站qq群推广链接
  • 网站设计常用软件天津百度搜索排名优化
  • html5开发手机网站教程2022百度搜索风云榜
  • 做网站怎么备份数据seo教程论坛
  • 长春 房地产网站建设安卓手机游戏优化器
  • 临沂做网站多少钱重庆网站推广联系方式
  • 加强 网站群建设管理windows优化大师最新版本
  • 有哪些网站制作公司泰安网站seo
  • 中石油七建设公司官网五年级下册数学优化设计答案
  • 山西省网站建设制作十大免费网站推广入口
  • 如何将自己做的网站推广出去seo建站平台哪家好
  • 怎样做国外网站推广2023年又封城了
  • 公司做网站需要提供什么磁力兔子搜索引擎
  • php做网站用什么软件网络seo优化平台
  • 个人订阅号支持微网站的建设吗软件推广怎么做
  • 免费手机网站开发微信营销方法
  • 去哪找网站建设公司好seo技术培训教程视频
  • 建设h网站风险大吗营销咨询公司排名
  • 网站开发面试都会问什么问题今日头条新闻下载安装
  • 全球疫情最新实时动态地图seo搜索引擎优化内容
  • 靠谱的建站公司哪家专业短链接在线生成
  • 无锡seoseo如何优化的