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

重庆哪家做网站好移动网站建设动态

重庆哪家做网站好,移动网站建设动态,怎么建网站卖产品,有没有免费开网站的1、项目介绍 1#xff09;项目功能 用户管理#xff1a;分为管理员、和普通用户#xff0c;设置不同用户的权限 电话本信息管理#xff1a;支持管理员和普通用户对电话本的信息进行增删改操作#xff0c;模糊查询#xff08;根据姓名、地址、单位#xff09; 文件批…1、项目介绍 1项目功能 用户管理分为管理员、和普通用户设置不同用户的权限 电话本信息管理支持管理员和普通用户对电话本的信息进行增删改操作模糊查询根据姓名、地址、单位  文件批量导入支持管理员通过excel文件批量导入电话本信息  分页功能对电话本信息管理页面支持分页查看  电话本分组管理对电话本进行分组修改、移动、删除  邮件发送名片功能支持管理员根据电话本信息向用户发送邮件邮件内容为个人信息名片和附件  用户信息导出功能导出个人用户的用户信息word文档  2技术栈描述 前端 htmlthymeleafjquerycss 后端 Spring Boot Spring MVC MyBatis Plus 数据库 MySQL 其他技术 POI Excel 、word文件导入导出、JavaMail API邮件发送 2、邮件发送具体实现 1导入发送邮件需要的依赖 !-- 邮件发送--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-mail/artifactId/dependency 2添加邮件配置的参数在application.yml配置文件中) mail:host: smtp.qq.com #qq邮件服务器地址 有其他地址username: xxxxxxxqq.com #发件人邮箱password: rwcafxsrjxfndfee #授权码default-encoding: UTF-8 #邮件登录字符集编码port: 25 #发件人邮件服务器端口 授权码的获取首先登录QQ邮箱登录成功后找到设置然后找到邮箱设置点击账户找到POP3|SMTP服务点击开启(开启需要验证验证成功后会有一串授权码用于发送邮件使用)验证成功 3创建邮件发送controller 以发送个人信息为例 AutowiredMailUtil mailUtil;/*** 邮件发送名片功能* param contactId* param userId* return*/RequestMapping(/sendEmailCard)public void sendEmailCard(Integer contactId, Integer userId){Contacts contacts this.contactsService.getById(contactId);Users user this.usersService.getById(contacts.getUserId());Integer gender0 contacts.getGender();String gender 男;if(gender01){gender女;}String email contacts.getEmail();String contenthtmlbodyh1个人名片/h1p姓名 user.getUsername()/pp单位 contacts.getCompany()/pp性别 gender/pp年龄 contacts.getAge()/pp办公电话 contacts.getOfficePhone()/pp传真 contacts.getFax()/pp手机号码 contacts.getMobile()/pp电子邮件 contacts.getEmail()/pp地址 contacts.getAddress()/pp备注 contacts.getRemarks()/p/body/html;String imgPath D:\\email\\个人信息表.docx;mailUtil.sendAttachmentsMail(email, 主题电话信息验证, content, imgPath);}4) 引入邮件发送工具包 package com.qcby.onlinephonebook.util;import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.FileSystemResource; import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.stereotype.Component;import javax.mail.MessagingException; import javax.mail.internet.MimeMessage; import java.io.File;/*** pp/** Author: porridge* Date:2022/3/30 10:17*/ Component public class MailUtil {Value(${spring.mail.username})String from;AutowiredJavaMailSender mailSender;//简单邮件public void sendSimpleMail(String to, String subject, String content){SimpleMailMessage message new SimpleMailMessage();message.setFrom(from); //发件人message.setTo(to);//收件人message.setSubject(subject); //标题message.setText(content); //文件内容try {mailSender.send(message);System.out.println(简单邮件发送成功);} catch (Exception e){System.out.println(发送简单邮件时发生异常e);}}//html格式邮件public void sendHtmlMail(String to, String subject, String content){MimeMessage message mailSender.createMimeMessage();try {//true表示需要创建一个multipart messageMimeMessageHelper helper new MimeMessageHelper(message, true);helper.setFrom(from);helper.setTo(to);helper.setSubject(subject);helper.setText(content, true);mailSender.send(message);System.out.println(html邮件发送成功!);} catch (MessagingException e) {System.out.println(发送html邮件时发生异常e);}}//带附件的邮件public void sendAttachmentsMail(String to, String subject, String content, String filePath){MimeMessage message mailSender.createMimeMessage();try {MimeMessageHelper helper new MimeMessageHelper(message, true);helper.setFrom(from);helper.setTo(to);helper.setSubject(subject);helper.setText(content, true);FileSystemResource file new FileSystemResource(new File(filePath));String fileName filePath.substring(filePath.lastIndexOf(File.separator));helper.addAttachment(fileName, file);mailSender.send(message);System.out.println(带附件的邮件已经发送。);} catch (MessagingException e) {System.out.println(发送带附件的邮件时发生异常 e);}}//带静态资源的邮件public void sendInlineResourceMail(String to, String subject, String content, String rscPath, String rscId){MimeMessage message mailSender.createMimeMessage();try {MimeMessageHelper helper new MimeMessageHelper(message, true);helper.setFrom(from);helper.setTo(to);helper.setSubject(subject);helper.setText(content, true);FileSystemResource res new FileSystemResource(new File(rscPath));helper.addInline(rscId, res);mailSender.send(message);System.out.println(嵌入静态资源的邮件已经发送。);} catch (MessagingException e) {System.out.println(发送嵌入静态资源的邮件时发生异常 e);}} } 发送成功样例 3、word导出具体实现 1实现思路 ①组装数据 ②获取根目录创建模板文件 ③将模板文件写入到根目录 ④编译模板渲染数据 ⑤写入到指定目录位置临时文件 ⑥提供前端下载 ⑦删除临时文件 2导入word导出需要的依赖 !-- word导出--dependencygroupIdcom.deepoove/groupIdartifactIdpoi-tl/artifactIdversion1.10.0/version/dependencydependencygroupIdorg.apache.poi/groupIdartifactIdpoi/artifactIdversion4.1.2/version/dependencydependencygroupIdorg.apache.poi/groupIdartifactIdpoi-ooxml/artifactIdversion4.1.2/version/dependency 3在项目resource目录下创建word模板 word模板如下 根据需要{{}}里面写入需要写入的参数名 4创建word导出的controller /*** 个人信息word导出* param response*/RequestMapping(/exportWord)public void exportWord(Integer contactId, Integer userId, HttpServletResponse response) {Contacts contacts this.contactsService.getById(contactId);String gender 男;if(contacts.getGender()1){gender 女;}//1.组装数据MapString, Object params new HashMap();params.put(name,contacts.getName());params.put(company, contacts.getCompany());params.put(gender, gender);params.put(age, contacts.getAge());params.put(officePhone, contacts.getOfficePhone());params.put(fax, contacts.getFax());params.put(mobile, contacts.getMobile());params.put(email, contacts.getEmail());params.put(address, contacts.getAddress());params.put(remarks, contacts.getRemarks());//2.获取根目录创建模板文件String path copyTempFile(word/info.docx);String fileName System.currentTimeMillis() .docx;String tmpPath D:\\email\\ fileName;try {//3.将模板文件写入到根目录//4.编译模板渲染数据XWPFTemplate template XWPFTemplate.compile(path).render(params);//5.写入到指定目录位置FileOutputStream fos new FileOutputStream(tmpPath);template.write(fos);fos.flush();fos.close();template.close();//6.提供前端下载down(response, tmpPath, fileName);} catch (Exception e) {e.printStackTrace();} finally {//7.删除临时文件File file new File(tmpPath);file.delete();File copyFile new File(path);copyFile.delete();}}/*** 用于将文件下载到客户端* param response* param filePath 文件路径* param realFileName 文件名称*/private void down(HttpServletResponse response, String filePath, String realFileName) {String percentEncodedFileName null;try {percentEncodedFileName percentEncode(realFileName);} catch (UnsupportedEncodingException e) {throw new RuntimeException(e);}StringBuilder contentDispositionValue new StringBuilder();contentDispositionValue.append(attachment; filename).append(percentEncodedFileName).append(;).append(filename*).append(utf-8).append(percentEncodedFileName);response.addHeader(Access-Control-Allow-Origin, *);response.addHeader(Access-Control-Expose-Headers, Content-Disposition,download-filename);response.setHeader(Content-disposition, contentDispositionValue.toString());response.setHeader(download-filename, percentEncodedFileName);try (BufferedInputStream bis new BufferedInputStream(new FileInputStream(filePath));// 输出流BufferedOutputStream bos new BufferedOutputStream(response.getOutputStream());) {byte[] buff new byte[1024];int len 0;while ((len bis.read(buff)) 0) {bos.write(buff, 0, len);}} catch (Exception e) {e.printStackTrace();}}/*** 百分号编码工具方法* param s 需要百分号编码的字符串* return 百分号编码后的字符串*/public static String percentEncode(String s) throws UnsupportedEncodingException {String encode URLEncoder.encode(s, StandardCharsets.UTF_8.toString());return encode.replaceAll(\\, %20);}/*** 复制模板文件用于写入得到临时路径* param s 模板文件的路径* return*/private String copyTempFile(String s) {InputStream inputStream getClass().getClassLoader().getResourceAsStream(s);String tempFileName System.getProperty(user.home) / info.docx;File tempFile new File(tempFileName);try {FileUtils.copyInputStreamToFile(inputStream, tempFile);} catch (IOException e) {throw new RuntimeException(e);}return tempFile.getPath();}导出成功样例
http://www.hkea.cn/news/14262960/

相关文章:

  • 快速进入网站wordpress后台相应慢
  • 门户建设网站多少钱wordpress添加商品画廊
  • 网站建设一年能收入多少钱公司注册查重名
  • 怎么做收费网站雅安市建设网站
  • 好看的网站在哪里好找河南省建设厅网网站首页
  • 网站关键字布局美食网站建设策划书
  • 网上做图赚钱的网站怎么做品牌的官方网站
  • 网站建设服务费怎么写分录网站建设后台 手工上传
  • 湖北专业网站制作公司手机网站广告
  • 淘宝网中国站电脑版登录河南住房和城乡建设厅门户网站
  • 有关建筑的网站大庆北京网站建设
  • 网站建设栏目管理天津建设网站c2成绩查询
  • 东营建设网站网站建设栏目这一块怎么写
  • 手机网站 微信支付小型外包公司在哪找项目
  • 免费网站如何被百度收录优惠网站怎么做
  • 用.net做购物网站一个外国人做的汉子 网站
  • 广州营销型网站建设费用龙岗同乐社区网站建设
  • 网站模版制作教程佛山seo
  • 广州营销型网站建设哪家好网站前置审批 公司名称
  • 老薛主机做电影网站网页设计要学所有软件吗
  • 贵阳网站开发公司网址转短链接
  • 品牌网站首页设计dw网站开发环境搭建
  • 自己做网站php好做吗wordpress 帮助 主题
  • 资讯网站源码wordpress extra script
  • 曹县住房和城乡建设部网站芜湖县建设局网站
  • 企业网站源码asp做公司网站需要准备什么资料
  • 青岛外贸网站建设哪家好网站html地图制作
  • 扬州网站建设网站婚庆网站模板下载
  • 天津网站建设首选 津坤科技传媒公司 网站开发
  • 一般可以建些什么种类的网站互联网做网站属于什么行业