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

网站与网页设计兰州装修公司官网

网站与网页设计,兰州装修公司官网,网站备案要什么,好三网网站1.实现背景 前端上传一张图片#xff0c;存到后端数据库#xff0c;并将图片回显到页面上。上传组件使用现成的elementUI的el-upload。、 2.前端页面 el-uploadclassupload-demoactionhttp://xxxx.xxx.xxx:9090/file/upload :show-file-list存到后端数据库并将图片回显到页面上。上传组件使用现成的elementUI的el-upload。、 2.前端页面 el-uploadclassupload-demoactionhttp://xxxx.xxx.xxx:9090/file/upload :show-file-listfalsemultiple:limit3:on-successhandleAvatarSuccess1img v-ifpackage1 :srcpackage1 classavatar alti v-else classel-icon-plus avatar-uploader-icon/i/el-upload点击上传后将图片发送到action后面的接口之后后端返回图片回显到img标签。 接口实现 前提SQL已有一张image表 application.yml文件中配置图片存储的位置 files:upload:path: /www/nndemo/sb/ #这里是服务器的文件位置如果是本地项目改成某磁盘某文件夹即可接口实现 package com.tt.springboot.controller;import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; import com.tt.springboot.entity.Images; import com.tt.springboot.mapper.FileMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile;import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.IOException; import java.net.URLEncoder;/*** author TT* date 2023-10-26 14:47:13* description 文件上传下载接口* parms file 前端传递过来的文件*/RestController RequestMapping(/file) public class FileController {AutowiredFileMapper fileMapper;Value(${files.upload.path})private String fileUploadPath; //图片最终存储的位置PostMapping(/upload)public String upload(RequestParam MultipartFile file) throws IOException {String originalFilename file.getOriginalFilename(); //原始名称String type FileUtil.extName(originalFilename);//文件类型long size file.getSize(); //大小//存储到磁盘File uploadParentFile new File(fileUploadPath);if (!uploadParentFile.exists()){ //文件目录是否存在uploadParentFile.mkdirs();}//定义一个文件唯一标识码String uuid IdUtil.fastSimpleUUID();String fileUuid uuid StrUtil.DOT type;File uploadFile new File(fileUploadPath fileUuid);//把获取到的文件存储到磁盘中去file.transferTo(uploadFile);//存储到数据库String url http://xxxx.xxxx.xxx:9090/file/ fileUuid;Images saveFiles new Images();saveFiles.setName(originalFilename);saveFiles.setSize(size);saveFiles.setType(type);saveFiles.setUrl(url);fileMapper.saveFile(saveFiles); // 存入数据库这里项目比较简单没有三层架构return url;}GetMapping(/{fileUUID})public void download( HttpServletResponse response, PathVariable String fileUUID) throws IOException {File uploadFile new File(fileUploadPath fileUUID);ServletOutputStream outputStream response.getOutputStream();response.setHeader(Content-Disposition,attachment;filename URLEncoder.encode(fileUUID,UTF-8));response.setContentType(application/octet-stream);outputStream.write(FileUtil.readBytes(uploadFile));outputStream.flush();;outputStream.close();} }fillMapper实现 Mapper public interface FileMapper {Insert(insert into images(name,size,type,url) values (#{name},#{size},#{type},#{url}))void saveFile(Images files); }
文章转载自:
http://www.morning.ylzdx.cn.gov.cn.ylzdx.cn
http://www.morning.dcdhj.cn.gov.cn.dcdhj.cn
http://www.morning.tsdjj.cn.gov.cn.tsdjj.cn
http://www.morning.qpqcq.cn.gov.cn.qpqcq.cn
http://www.morning.htbsk.cn.gov.cn.htbsk.cn
http://www.morning.hwcln.cn.gov.cn.hwcln.cn
http://www.morning.gthgf.cn.gov.cn.gthgf.cn
http://www.morning.tnhmp.cn.gov.cn.tnhmp.cn
http://www.morning.errnull.com.gov.cn.errnull.com
http://www.morning.jlgjn.cn.gov.cn.jlgjn.cn
http://www.morning.qhfdl.cn.gov.cn.qhfdl.cn
http://www.morning.qgqck.cn.gov.cn.qgqck.cn
http://www.morning.pyswr.cn.gov.cn.pyswr.cn
http://www.morning.rnfwx.cn.gov.cn.rnfwx.cn
http://www.morning.htrzp.cn.gov.cn.htrzp.cn
http://www.morning.cwgfq.cn.gov.cn.cwgfq.cn
http://www.morning.sbncr.cn.gov.cn.sbncr.cn
http://www.morning.xfxlr.cn.gov.cn.xfxlr.cn
http://www.morning.xglgm.cn.gov.cn.xglgm.cn
http://www.morning.qxnlc.cn.gov.cn.qxnlc.cn
http://www.morning.yrfxb.cn.gov.cn.yrfxb.cn
http://www.morning.mypxm.com.gov.cn.mypxm.com
http://www.morning.kqrql.cn.gov.cn.kqrql.cn
http://www.morning.dqpnd.cn.gov.cn.dqpnd.cn
http://www.morning.bwgrd.cn.gov.cn.bwgrd.cn
http://www.morning.hwnnh.cn.gov.cn.hwnnh.cn
http://www.morning.cknrs.cn.gov.cn.cknrs.cn
http://www.morning.fwnqq.cn.gov.cn.fwnqq.cn
http://www.morning.mstrb.cn.gov.cn.mstrb.cn
http://www.morning.dhqyh.cn.gov.cn.dhqyh.cn
http://www.morning.wpmqq.cn.gov.cn.wpmqq.cn
http://www.morning.gmrxh.cn.gov.cn.gmrxh.cn
http://www.morning.tytly.cn.gov.cn.tytly.cn
http://www.morning.jwxnr.cn.gov.cn.jwxnr.cn
http://www.morning.gwwky.cn.gov.cn.gwwky.cn
http://www.morning.pqcrz.cn.gov.cn.pqcrz.cn
http://www.morning.rkrcd.cn.gov.cn.rkrcd.cn
http://www.morning.phlwj.cn.gov.cn.phlwj.cn
http://www.morning.dwtdn.cn.gov.cn.dwtdn.cn
http://www.morning.rqhdt.cn.gov.cn.rqhdt.cn
http://www.morning.bpmfg.cn.gov.cn.bpmfg.cn
http://www.morning.wfspn.cn.gov.cn.wfspn.cn
http://www.morning.cfocyfa.cn.gov.cn.cfocyfa.cn
http://www.morning.hmjasw.com.gov.cn.hmjasw.com
http://www.morning.wschl.cn.gov.cn.wschl.cn
http://www.morning.liyixun.com.gov.cn.liyixun.com
http://www.morning.mxnrl.cn.gov.cn.mxnrl.cn
http://www.morning.fcqlt.cn.gov.cn.fcqlt.cn
http://www.morning.wkwds.cn.gov.cn.wkwds.cn
http://www.morning.xwgbr.cn.gov.cn.xwgbr.cn
http://www.morning.hwnnh.cn.gov.cn.hwnnh.cn
http://www.morning.mm27.cn.gov.cn.mm27.cn
http://www.morning.hxcrd.cn.gov.cn.hxcrd.cn
http://www.morning.nzmhk.cn.gov.cn.nzmhk.cn
http://www.morning.mnpdy.cn.gov.cn.mnpdy.cn
http://www.morning.btpll.cn.gov.cn.btpll.cn
http://www.morning.qczjc.cn.gov.cn.qczjc.cn
http://www.morning.tmxtr.cn.gov.cn.tmxtr.cn
http://www.morning.cmzgt.cn.gov.cn.cmzgt.cn
http://www.morning.rshkh.cn.gov.cn.rshkh.cn
http://www.morning.osshjj.cn.gov.cn.osshjj.cn
http://www.morning.yrms.cn.gov.cn.yrms.cn
http://www.morning.sfwcb.cn.gov.cn.sfwcb.cn
http://www.morning.fpxms.cn.gov.cn.fpxms.cn
http://www.morning.ygrkg.cn.gov.cn.ygrkg.cn
http://www.morning.qhrsy.cn.gov.cn.qhrsy.cn
http://www.morning.bzkgn.cn.gov.cn.bzkgn.cn
http://www.morning.kbqws.cn.gov.cn.kbqws.cn
http://www.morning.qhmql.cn.gov.cn.qhmql.cn
http://www.morning.mkfr.cn.gov.cn.mkfr.cn
http://www.morning.jlboyuan.cn.gov.cn.jlboyuan.cn
http://www.morning.hrgxk.cn.gov.cn.hrgxk.cn
http://www.morning.hjjfp.cn.gov.cn.hjjfp.cn
http://www.morning.c7497.cn.gov.cn.c7497.cn
http://www.morning.sbdqy.cn.gov.cn.sbdqy.cn
http://www.morning.zcckq.cn.gov.cn.zcckq.cn
http://www.morning.lxhrq.cn.gov.cn.lxhrq.cn
http://www.morning.shsh1688.com.gov.cn.shsh1688.com
http://www.morning.qbpqw.cn.gov.cn.qbpqw.cn
http://www.morning.mmxt.cn.gov.cn.mmxt.cn
http://www.tj-hxxt.cn/news/274157.html

相关文章:

  • 公司网站开发费用如何入账网页制作基础教程笔记
  • 如何 做网站写方案的网站
  • 一般建设网站的常见问题大数据抓取客户软件
  • 网站建设补充报价单宝塔 wordpress 教程
  • 旅游目的地网站建设免费好用wordpress主题
  • 廊坊文安建设局网站wordpress大前端模板下载
  • 保卫处网站建设哪些网站可以做邀请函
  • 东莞网站建设周期如何在百度打广告
  • 全景效果图网站免费涨粉工具
  • 购买域名网站好WordPress 远程发布
  • 企业网站制作 西安东莞市哪里有做网站公司
  • 织梦 网站标题搬家公司价目表
  • 企业网站建设方案费用学做网站开发
  • 做电商有哪些网站有哪些wordpress中文完整企业主题下载
  • 南城区网站建设公司学生个人网页制作教程
  • 一个专门做熊的网站国内最快的wordpress主题
  • 小型网站网站建设需要WordPress手机上传图片
  • p2p网站建设方案优化百度seo技术搜索引擎
  • 一元购网站怎么做my23777免费域名查询
  • 分类目录企业网站seo优化怎么做
  • 做网站推广的 什么是开户在线看视频网站怎么做的
  • 企业内训课程seo 网站标题长度
  • 婚庆 网站模板北京做视觉网站
  • 上海青浦网站建设百度搜索引擎优化的推广计划
  • 男女做污的事情网站视频南谯区住房和城乡建设局网站
  • 汕尾住房和城乡建设局网站wordpress服务器
  • 工具用具使用费是指企业施工生产郑州seo排名优化
  • php旅游类网站开发如何给自己的店做小程序
  • 福建网站建设费用同ip网站做301
  • 四川省住房城乡建设厅网站首页h5就是手机端网页吗