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

企业不开了网站备案吗网站安全建设方案前言

企业不开了网站备案吗,网站安全建设方案前言,怎样使用仿站小工具做网站,中国中小企业网官方网站目录 1、文件上传本地 1.1 原理 1.2 如何使用文件上传 1.2.1 引入文件上传的依赖 1.2.2 配置文件上传拦截器 1.2.3 完成文件上传的代码 2、文件上传oss服务器 2.1 为什么需要上传到oss服务器 2.2 如何使用oss 2.2.1 开启oss服务 2.2.2 在Java中引入依赖 2.2.3 查看自…目录 1、文件上传本地 1.1 原理 1.2 如何使用文件上传 1.2.1 引入文件上传的依赖 1.2.2 配置文件上传拦截器 1.2.3 完成文件上传的代码 2、文件上传oss服务器  2.1 为什么需要上传到oss服务器 2.2 如何使用oss  2.2.1 开启oss服务 2.2.2 在Java中引入依赖 2.2.3 查看自己ID和密钥 2.2.4 代码 3、案例 3.1 引入相关依赖  3.2  创建实体类 3.3 创建controller层 3.3.1 创建StudentController 3.3.2 创建UploadController 3.4 创建dao层 3.4.1 BaseDao 3.4.2 StudentDao 3.5 配置SpringMvc配置文件 3.6 编写upload.jsp文件 1、文件上传本地 1.1 原理 1.2 如何使用文件上传 1.2.1 引入文件上传的依赖 dependenciesdependencygroupIdorg.springframework/groupIdartifactIdspring-webmvc/artifactIdversion5.2.10.RELEASE/version/dependencydependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdversion1.18.24/version/dependency!--servlet依赖--dependencygroupIdjavax.servlet/groupIdartifactIdjavax.servlet-api/artifactIdversion3.1.0/version/dependency!--jackson依赖:把controller层方法返回的java对象转化为json字符串--dependencygroupIdcom.fasterxml.jackson.core/groupIdartifactIdjackson-databind/artifactIdversion2.13.3/version/dependency!--文件上传依赖--dependencygroupIdcommons-fileupload/groupIdartifactIdcommons-fileupload/artifactIdversion1.4/version/dependency/dependencies 1.2.2 配置文件上传拦截器 !--文件上传解析器 id:必须为multipartResolver--bean idmultipartResolver classorg.springframework.web.multipart.commons.CommonsMultipartResolver!--设置文件上传的大小 单位为byte字节 1M1024kb1024b 10*1024*1024--property namemaxUploadSize value10485760/!--设置编码--property namedefaultEncoding valueutf-8//bean1.2.3 完成文件上传的代码 %--表单: 提交方式必须为post enctype编码:multipart/form-data文件编码--%form methodpost action/upload enctypemultipart/form-data%--input必须设置文件文件框 而且必须起名称--%选择上传的文件:input typefile namemyfile/brinput typesubmit value上传//form Controller public class UploadController {/**** param myfile 接受你上传的文件对象信息封装到该类。该类中可以获取上传文件的信息。比如:文件名 文件大小 文件后缀等* 这个名称必须为文件上传表单的文件框的名称一致* return*/PostMapping(/upload)public String upload(MultipartFile myfile, HttpServletRequest request) throws IOException {//获取tomcat上下文中的指定目录的路径String realPath request.getSession().getServletContext().getRealPath(/upload);//根据上面的路径创建一个文件对象File filenew File(realPath);//如果没有该目录则创建if (!file.exists()) {file.mkdirs();}//把上传的文件转移到upload目录下--重名覆盖了String uuid UUID.randomUUID().toString().replace(-, );File targetnew File(realPath/(uuidmyfile.getOriginalFilename()));myfile.transferTo(target);return success;} } 2、文件上传oss服务器  2.1 为什么需要上传到oss服务器 如果项目搭建了集群。那么导致文件数据无法共享。 如果项目的target删除了。导致文件数据丢失。 2.2 如何使用oss  2.2.1 开启oss服务 oss服务器网址 点击上面链接跳转到阿里云的oss服务器页面完成登录后会进入oss管理控制台如图所示 然后点击创建Bucket操作如下图 2.2.2 在Java中引入依赖 dependencygroupIdcom.aliyun.oss/groupIdartifactIdaliyun-sdk-oss/artifactIdversion3.15.1/version /dependency 2.2.3 查看自己ID和密钥 2.2.4 代码 PostMapping(/upload2)public String upload2(MultipartFile myfile){// Endpoint以华东1杭州为例其它Region请按实际情况填写。String endpoint oss-cn-beijing.aliyuncs.com;// 填写Bucket名称例如examplebucket。String bucketName XXXXX;//上传到oss后的名字String objectName UUID.randomUUID().toString().replace(-,)myfile.getOriginalFilename();// 创建OSSClient实例。/*** String endpoint,自己的endpoint* String accessKeyId, 自己的id* String secretAccessKey自己的密钥*/String accessKeyIdXXXXXXX;String secretAccessKeyXXXXXXX;OSS ossClient new OSSClientBuilder().build(endpoint,accessKeyId,secretAccessKey);try {InputStream inputStream myfile.getInputStream();// 创建PutObjectRequest对象。PutObjectRequest putObjectRequest new PutObjectRequest(bucketName, objectName, inputStream);// 创建PutObject请求。PutObjectResult result ossClient.putObject(putObjectRequest);} catch (Exception oe) {}finally {if (ossClient ! null) {ossClient.shutdown();}}return success;} 3、案例 springmvcjdbcelementuivue 添加和展示所有的功能 3.1 引入相关依赖  ?xml version1.0 encodingUTF-8?project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersiongroupIdcom.ykq/groupIdartifactIdqy174-springmvc04/artifactIdversion1.0-SNAPSHOT/versionpackagingwar/packagingdependenciesdependencygroupIdorg.springframework/groupIdartifactIdspring-webmvc/artifactIdversion5.2.10.RELEASE/version/dependencydependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdversion1.18.24/version/dependency!--servlet依赖--dependencygroupIdjavax.servlet/groupIdartifactIdjavax.servlet-api/artifactIdversion3.1.0/version/dependency!--jackson依赖:把controller层方法返回的java对象转化为json字符串--dependencygroupIdcom.fasterxml.jackson.core/groupIdartifactIdjackson-databind/artifactIdversion2.13.3/version/dependency!--文件上传依赖--dependencygroupIdcommons-fileupload/groupIdartifactIdcommons-fileupload/artifactIdversion1.4/version/dependency!--oss的依赖--dependencygroupIdcom.aliyun.oss/groupIdartifactIdaliyun-sdk-oss/artifactIdversion3.15.1/version/dependency!--mysql的jar--dependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactIdversion8.0.28/version/dependency!--druid--dependencygroupIdcom.alibaba/groupIdartifactIddruid/artifactIdversion1.2.8/version/dependency/dependencies /project 3.2  创建实体类 Data public class Student implements Serializable {private Integer id;private String name;private String phone;private String email;private Integer age;private Byte gender;private Date createtime;private String head;} 3.3 创建controller层 3.3.1 创建StudentController Controller RequestMapping(/student) public class StudentController {private StudentDao studentDaonew StudentDao();GetMapping(/list)ResponseBody //把java对象转化为json字符串public ListStudent list(){ListStudent list studentDao.findAll();return list;}PostMapping(/add)ResponseBody //把java对象转化为json字符串public int add(RequestBody Student student){int add studentDao.add(student.getName(), student.getPhone(), student.getEmail(), student.getAge(), student.getGender(), student.getHead());return add;} } 3.3.2 创建UploadController Controller public class UploadController {/**** param myfile 接受你上传的文件对象信息封装到该类。该类中可以获取上传文件的信息。比如:文件名 文件大小 文件后缀等* 这个名称必须为文件上传表单的文件框的名称一致* return*/PostMapping(/upload)public String upload(MultipartFile myfile, HttpServletRequest request) throws IOException {//获取tomcat上下文中的指定目录的路径String realPath request.getSession().getServletContext().getRealPath(/upload);//根据上面的路径创建一个文件对象File filenew File(realPath);//如果没有该目录则创建if (!file.exists()) {file.mkdirs();}//把上传的文件转移到upload目录下--重名覆盖了String uuid UUID.randomUUID().toString().replace(-, );File targetnew File(realPath/(uuidmyfile.getOriginalFilename()));myfile.transferTo(target);return success;}PostMapping(/upload2)ResponseBodypublic String upload2(MultipartFile file){// Endpoint以华东1杭州为例其它Region请按实际情况填写。String endpoint oss-cn-beijing.aliyuncs.com;// 填写Bucket名称例如examplebucket。String bucketName qy174-8888;//上传到oss后的名字String objectName UUID.randomUUID().toString().replace(-,)file.getOriginalFilename();// 创建OSSClient实例。/*** String endpoint,自己的endpoint* String accessKeyId, 自己的id* String secretAccessKey自己的密钥* XX* XXX*/String accessKeyIdXXX;String secretAccessKeyXXX;OSS ossClient new OSSClientBuilder().build(endpoint,accessKeyId,secretAccessKey);try {InputStream inputStream file.getInputStream();// 创建PutObjectRequest对象。PutObjectRequest putObjectRequest new PutObjectRequest(bucketName, objectName, inputStream);// 创建PutObject请求。PutObjectResult result ossClient.putObject(putObjectRequest);String pathhttps://bucketName.endpoint/objectName;return path;} catch (Exception oe) {}finally {if (ossClient ! null) {ossClient.shutdown();}}return 失败;} }3.4 创建dao层 3.4.1 BaseDao public class BaseDao {protected Connection conn;protected PreparedStatement ps;protected ResultSet rs;//数据源对象private static DataSource dataSource;//静态代码块中static {try {//创建一个属性对象Properties properties new Properties();//加载属性文件InputStream inputStream BaseDao.class.getClassLoader().getResourceAsStream(db.properties);properties.load(inputStream);//获取连接池对象dataSource DruidDataSourceFactory.createDataSource(properties);} catch (Exception e) {e.printStackTrace();}}//获取连接对象public void getConn() throws Exception{conn dataSource.getConnection();}//关闭资源public void closeAll(){if(rs!null){try {rs.close();} catch (SQLException throwables) {throwables.printStackTrace();}}if(ps!null){try {ps.close();} catch (SQLException throwables) {throwables.printStackTrace();}}if(conn!null){try {conn.close();} catch (SQLException throwables) {throwables.printStackTrace();}}}//通用的增删改方法public int edit(String sql,Object...params){try {getConn();psconn.prepareStatement(sql);//为占位符赋值for(int i0;iparams.length;i){ps.setObject(i1,params[i]);}int row ps.executeUpdate();return row;} catch (Exception e) {e.printStackTrace();} finally {closeAll();}return 0;}} /**1. 四个属性: connection preparedStatement ResultSet DataSource2. 静态代码块:[获取连接池]3. 获取连接对象的方法4. 关闭资源方法5. 通用的增删改方法*/ 3.4.2 StudentDao public class StudentDao extends BaseDao {//求总条数 select count(*) from t_studentpublic int getCount(){try {getConn();String sqlselect count(*) as c from t_student;psconn.prepareStatement(sql);rsps.executeQuery();while (rs.next()){int c rs.getInt(c);return c;}} catch (Exception e) {e.printStackTrace();} finally {closeAll();}return 0;}//查询所有学员信息--单元测试public ListStudent findAll(){ListStudent listnew ArrayListStudent();try {getConn();String sqlselect * from t_student;psconn.prepareStatement(sql);rsps.executeQuery();while (rs.next()){Student snew Student();s.setId(rs.getInt(id));s.setPhone(rs.getString(phone));s.setEmail(rs.getString(email));s.setAge(rs.getInt(age));s.setName(rs.getString(name));s.setCreatetime(rs.getDate(createtime));s.setGender(rs.getByte(gender));s.setHead(rs.getString(head));list.add(s);}} catch (Exception e) {e.printStackTrace();} finally {closeAll();}return list;}//根据id查询学员信息public Student findById(String id){Student snull;try {getConn();String sqlselect * from t_student where id?;psconn.prepareStatement(sql);ps.setObject(1,id);rsps.executeQuery();while (rs.next()){snew Student();s.setId(rs.getInt(id));s.setPhone(rs.getString(phone));s.setEmail(rs.getString(email));s.setAge(rs.getInt(age));s.setName(rs.getString(name));s.setCreatetime(rs.getDate(createtime));s.setGender(rs.getByte(gender));s.setHead(rs.getString(head));}} catch (Exception e) {e.printStackTrace();} finally {closeAll();}return s;}//添加方法public int add(String name,String phone,String email,int age,int gender,String head){String sqlinsert into t_student(id,name,phone,email,age,createtime,gender,head) values(null,?,?,?,?,now(),?,?);return edit(sql,name,phone,email,age,gender,head);}//修改public int update(String id,String name,String phone,String email,int age,int gender){String sqlupdate t_student set name?,phone?,email?,age?,gender?,createtimenow() where id?;return edit(sql,name,phone,email,age,gender,id);}//删除方法public int delete(String id){String sqldelete from t_student where id?;return edit(sql,id);} 3.5 配置SpringMvc配置文件 ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:contexthttp://www.springframework.org/schema/contextxmlns:mvchttp://www.springframework.org/schema/mvcxsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd!--com.ykq 扫描该包以及该包下的子包--context:component-scan base-packagecom.Hs/!--开启注解驱动 不要导错mvc 默认使用的不是注解模式--mvc:annotation-driven/!--放行静态资源--mvc:default-servlet-handler/!--视图解析--bean classorg.springframework.web.servlet.view.InternalResourceViewResolverproperty nameprefix value/views//property namesuffix value.jsp//bean!--文件上传解析器 id:必须为multipartResolver--bean idmultipartResolver classorg.springframework.web.multipart.commons.CommonsMultipartResolver!--设置文件上传的大小 单位为byte字节 1M1024kb1024b 10*1024*1024--property namemaxUploadSize value10485760/!--设置编码--property namedefaultEncoding valueutf-8//bean/beans 3.6 编写upload.jsp文件 % page contentTypetext/html;charsetUTF-8 languagejava % html headtitleTitle/title /head body%--表单: 提交方式必须为post enctype编码:multipart/form-data文件编码--%form methodpost action/upload2 enctypemultipart/form-data%--input必须设置文件文件框 而且必须起名称--%选择上传的文件:input typefile namemyfile/brinput typesubmit value上传//form /body /html
文章转载自:
http://www.morning.dcccl.cn.gov.cn.dcccl.cn
http://www.morning.fdmfn.cn.gov.cn.fdmfn.cn
http://www.morning.qlck.cn.gov.cn.qlck.cn
http://www.morning.jcnmy.cn.gov.cn.jcnmy.cn
http://www.morning.jbshh.cn.gov.cn.jbshh.cn
http://www.morning.ljxxl.cn.gov.cn.ljxxl.cn
http://www.morning.twhgn.cn.gov.cn.twhgn.cn
http://www.morning.clnmf.cn.gov.cn.clnmf.cn
http://www.morning.nywrm.cn.gov.cn.nywrm.cn
http://www.morning.cwtrl.cn.gov.cn.cwtrl.cn
http://www.morning.xglgm.cn.gov.cn.xglgm.cn
http://www.morning.ndmbz.cn.gov.cn.ndmbz.cn
http://www.morning.ybhrb.cn.gov.cn.ybhrb.cn
http://www.morning.wnnfh.cn.gov.cn.wnnfh.cn
http://www.morning.jzdfc.cn.gov.cn.jzdfc.cn
http://www.morning.knwry.cn.gov.cn.knwry.cn
http://www.morning.zgpgl.cn.gov.cn.zgpgl.cn
http://www.morning.fjntg.cn.gov.cn.fjntg.cn
http://www.morning.bmsqq.cn.gov.cn.bmsqq.cn
http://www.morning.wbysj.cn.gov.cn.wbysj.cn
http://www.morning.wqmpd.cn.gov.cn.wqmpd.cn
http://www.morning.mzhgf.cn.gov.cn.mzhgf.cn
http://www.morning.qcygd.cn.gov.cn.qcygd.cn
http://www.morning.mprpx.cn.gov.cn.mprpx.cn
http://www.morning.yrblz.cn.gov.cn.yrblz.cn
http://www.morning.mpgfk.cn.gov.cn.mpgfk.cn
http://www.morning.zttjs.cn.gov.cn.zttjs.cn
http://www.morning.mxnfh.cn.gov.cn.mxnfh.cn
http://www.morning.xphls.cn.gov.cn.xphls.cn
http://www.morning.lokext.com.gov.cn.lokext.com
http://www.morning.txysr.cn.gov.cn.txysr.cn
http://www.morning.jfch.cn.gov.cn.jfch.cn
http://www.morning.dshkp.cn.gov.cn.dshkp.cn
http://www.morning.lsgjf.cn.gov.cn.lsgjf.cn
http://www.morning.gchqy.cn.gov.cn.gchqy.cn
http://www.morning.gbybx.cn.gov.cn.gbybx.cn
http://www.morning.jzdfc.cn.gov.cn.jzdfc.cn
http://www.morning.syssdz.cn.gov.cn.syssdz.cn
http://www.morning.rfqk.cn.gov.cn.rfqk.cn
http://www.morning.nfbkz.cn.gov.cn.nfbkz.cn
http://www.morning.mgwpy.cn.gov.cn.mgwpy.cn
http://www.morning.wknbc.cn.gov.cn.wknbc.cn
http://www.morning.jrplk.cn.gov.cn.jrplk.cn
http://www.morning.xnwjt.cn.gov.cn.xnwjt.cn
http://www.morning.fqnql.cn.gov.cn.fqnql.cn
http://www.morning.gjcdr.cn.gov.cn.gjcdr.cn
http://www.morning.ghrlx.cn.gov.cn.ghrlx.cn
http://www.morning.gblrn.cn.gov.cn.gblrn.cn
http://www.morning.rbyz.cn.gov.cn.rbyz.cn
http://www.morning.hmdyl.cn.gov.cn.hmdyl.cn
http://www.morning.nxbsq.cn.gov.cn.nxbsq.cn
http://www.morning.kgxrq.cn.gov.cn.kgxrq.cn
http://www.morning.hsdhr.cn.gov.cn.hsdhr.cn
http://www.morning.jtszm.cn.gov.cn.jtszm.cn
http://www.morning.hhfqk.cn.gov.cn.hhfqk.cn
http://www.morning.rmfwh.cn.gov.cn.rmfwh.cn
http://www.morning.bnlsd.cn.gov.cn.bnlsd.cn
http://www.morning.kltmt.cn.gov.cn.kltmt.cn
http://www.morning.qwfl.cn.gov.cn.qwfl.cn
http://www.morning.rfrxt.cn.gov.cn.rfrxt.cn
http://www.morning.zgpgl.cn.gov.cn.zgpgl.cn
http://www.morning.rqlzz.cn.gov.cn.rqlzz.cn
http://www.morning.qbwtb.cn.gov.cn.qbwtb.cn
http://www.morning.ttdbr.cn.gov.cn.ttdbr.cn
http://www.morning.nfpct.cn.gov.cn.nfpct.cn
http://www.morning.gwdnl.cn.gov.cn.gwdnl.cn
http://www.morning.dmtwz.cn.gov.cn.dmtwz.cn
http://www.morning.pnjsl.cn.gov.cn.pnjsl.cn
http://www.morning.gslz.com.cn.gov.cn.gslz.com.cn
http://www.morning.btqrz.cn.gov.cn.btqrz.cn
http://www.morning.cnfxr.cn.gov.cn.cnfxr.cn
http://www.morning.ytmx.cn.gov.cn.ytmx.cn
http://www.morning.wptdg.cn.gov.cn.wptdg.cn
http://www.morning.mnwmj.cn.gov.cn.mnwmj.cn
http://www.morning.zlfxp.cn.gov.cn.zlfxp.cn
http://www.morning.qxbsq.cn.gov.cn.qxbsq.cn
http://www.morning.bntfy.cn.gov.cn.bntfy.cn
http://www.morning.hgsylxs.com.gov.cn.hgsylxs.com
http://www.morning.wpmqq.cn.gov.cn.wpmqq.cn
http://www.morning.qdxkn.cn.gov.cn.qdxkn.cn
http://www.tj-hxxt.cn/news/264016.html

相关文章:

  • 帝国cms调用网站地址设计网站推荐按钮的作用
  • 电销如何介绍网站建设wordpress 首页缩列图
  • 重庆网站建设公司招聘购物商城网站建设多少钱
  • 海康打开网站显示建设中莱芜seo
  • 网站建设公司 盐城市重庆大渡口营销型网站建设价格
  • 电子商务网站建设的基本要求支付宝小程序推广
  • 免费自助建站做网站推广有作用没
  • 网站的优化承诺那个网站做网站托管
  • 网站统计哪个好用东莞百度seo在哪
  • wordpress评论回复邮箱湖北百度seo厂家
  • 做购物网站是怎么连接银行微信小程序官方电话
  • 自己网站做搜索引擎优化营销助手app
  • 网站建设 镇江网站开发+.net+开源
  • 江苏做网站怎么收费昆明网络公司排行榜
  • mvc 网站建设莆田网站自助建站
  • asp.net 实现 网站的开关企业管理培训
  • 一个网站上能不能放两个域名 两个备案号鞍山制作网站的公司
  • 建筑业企业资质标准建设部网站重庆建设工程交易网
  • 一个网站项目多少钱个人网站要备案吗
  • 网站做优化有什么好处泉州晋江网站建设
  • 连平网站建设北京市中关村有哪家可以做网站维护
  • 做网站路径福州短视频seo公司
  • 无锡网站排名优化费用网站建设技术入股协议
  • PHP网站建设视频免费卡点视频软件下载
  • 网站建设go网络推广公司怎么报税
  • 国外网站模板手机网站开发设计包括什么
  • 网站服务流程企业建设网站 入账
  • 三端合一网站开发的关键技术提升关键词排名seo软件
  • 在网上建设网站需要花钱么泰安人才市场官网
  • 简单网站建设的费用国内可用的免费云端服务器