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

网站备案的时候可以做网站吗wordpress小说文章发布插件

网站备案的时候可以做网站吗,wordpress小说文章发布插件,门户网站开发介绍,哪些是门户网站1. 文件上传 1.1 前端注意事项 文件上传操作#xff0c;前端的表单项需要如下三项设置#xff1a; #xff08;1#xff09;input标签的type属性应设置为file#xff0c;并且注意不要在input标签中设置value属性#xff0c;因为这可能导致文件上传不成功#xff1b; …1. 文件上传 1.1 前端注意事项 文件上传操作前端的表单项需要如下三项设置 1input标签的type属性应设置为file并且注意不要在input标签中设置value属性因为这可能导致文件上传不成功         2请求方式为 methodpost 3enctypemultipart/form-data。 1.2 后端注意事项 文件上传操作后端需要注意 1可以在项目的配置文件 application.properties或application.yml中设置文件大小限制以避免上传过大的文件导致服务器资源耗尽例如 2后端需要写一个处理上传文件的处理器把接收到的文件保存到服务器指定目录下等其他操作。 1.3 前后端完整示例程序 1.3.1 前端 !DOCTYPE html html langen xmlnshttp://www.w3.org/1999/html headmeta charsetUTF-8title文件上传和下载/title /head body form action/file/upload methodpost enctypemultipart/form-data用户名input typetext nameusername/br/头 像 input typefile nameheaderImg /br/生活照input typefile namelifeImages multiple/brinput typesubmit value提交/ /form /body /html 1.3.2 后端 package com.shg.springmvc.controller;import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile;import java.io.IOException; import java.nio.file.Paths;Controller public class PageTestController {RequestMapping(value /file/upload, method RequestMethod.POST)ResponseBodypublic String fileUpload(RequestParam(value headerImg) MultipartFile file,RequestParam(value lifeImages) MultipartFile[] lifeImages,RequestParam(value username) String userName) throws IOException {System.out.println(用户名 userName);System.out.println(头像 - 文件名称 file.getOriginalFilename());file.transferTo(Paths.get(D:\\tempPic\\ file.getOriginalFilename()));for (MultipartFile lifeImage : lifeImages) {System.out.println(生活照 - 文件名称 lifeImage.getOriginalFilename());lifeImage.transferTo(Paths.get(D:\\tempPic\\ file.getOriginalFilename()));}return success;} } 2. 文件下载 文件下载的写法比较固定代码如下 package com.shg.springmvc.controller;import org.springframework.core.io.InputStreamResource; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController;import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.net.URLEncoder; import java.nio.charset.StandardCharsets;RestController public class ResponseTestController {/*** 问题一如果文件名称中包含中文那么浏览器会乱码* 问题二如果下载的文件比较大会oom(内存溢出)** return* throws IOException*/RequestMapping(value /download, method RequestMethod.GET)public ResponseEntityInputStreamResource response_02() throws IOException {// 获取要下载的文件流String filePath D:\\tempPic\\生活照3.jpg;File file new File(filePath);FileInputStream fileInputStream new FileInputStream(file);// 解决问题一使用URLEncoder.encode()方法对文件名称进行编码String fileName URLEncoder.encode(你好啊.jpg, StandardCharsets.UTF_8);// 解决问题二为了避免一次性读取文件过大导致内存溢出可以使用 InputStreamResource 来读取文件(将文件流包装成Resource对象)InputStreamResource inputStreamResource new InputStreamResource(fileInputStream);return ResponseEntity.ok()// 设置响应头告诉浏览器如何处理.header(HttpHeaders.CONTENT_DISPOSITION, attachment; filename fileName)// 下载文件的大小.contentLength(file.length())// 内容类型:流.contentType(MediaType.APPLICATION_OCTET_STREAM)// 响应体.body(inputStreamResource);} }
http://www.w-s-a.com/news/120248/

相关文章:

  • 我做的网站手机上不了wordpress插件整站搬家
  • 河南省和建设厅网站首页西安找建网站公司
  • 网页设计基础代码网站进出成都最新通知
  • 如何创建网站乐清网络科技有限公司
  • 沈阳市网站制作艺术字体logo设计生成器
  • 网站设计常用软件都有哪些中国建设银行官方招聘网站
  • 证券投资网站建设视频直播怎么赚钱的
  • 建设酒店网站ppt模板下载郑州小程序设计外包
  • 网站建设自我总结google推广公司
  • 安全网站建设情况wordpress 评论表单
  • 网站建设发言材料个人网站推广软件
  • php建站软件哪个好南京哪家做网站好
  • 排名好的手机网站建设番禺网站建设专家
  • 番禺怎么读百度有专做优化的没
  • 网站开发中应注意哪些问题网络营销的主要特点
  • 网站定制案例北京网站制作招聘网
  • 网站建设与推广实训小结网站建设专业英文
  • 郑州网站建设动态凡科网站建设是免费的吗
  • 湖北手机网站建设wordpress转emlog博客
  • 北京东站设计网名的花样符号
  • 安徽建设厅网站首页网站开发aichengkeji
  • 自贡网站制作荣茂网站建设
  • 什么做的网站吗正规的机械外包加工订单网
  • 网络工程公司的业务邵阳seo快速排名
  • 博主怎么赚钱网站seo找准隐迅推
  • 营销号经典废话北京网站建设公司网站优化资讯
  • 一六八互联网站建设怎么做套版网站
  • wordpress 书站建筑公司简介范文大全
  • 建设官方网站多少鲜花网站建设的主要工作流程
  • 卖主机网站轻量wordpress主题