Web复习

文章目录:


前言

提示:这里可以添加本文要记录的大概内容:

例如:随着人工智能的不断发展,机器学习这门技术也越来越重要,很多人都开启了学习机器学习,本文就介绍了机器学习的基础内容。


提示:以下是本篇文章正文内容,下面案例可供参考

一、IO流

 1.输入流:

                字节输入流:InputStream

                字节输入流:Reader

2.输出流:

                字节输出流:OutputStream

                字符输入流:Writer

字节流是操作二进制文件的

字符流是操作字符的

如何读写文件,比如从c盘读到d盘:

    public static void main(String[] args)  throws Exception{
        FileInputStream in=new FileInputStream("E:/sa.png");
        FileOutputStream out=new FileOutputStream("D:/sb.png");
        byte[]  buf=new byte[1024];
        while (true) {
            int len=in.read(buf);
            if (len==-1) 
                break;
                out.write(buf,0,len);
            }
            in.close();
            out.close();
        }
    }

序列化与反序列化

对象——>流——>对象

作用:快速克隆一个对象

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Object obj =  super.clone();
        System.out.println("被克隆了...");
        return obj;
    }

    protected Object deepClone() throws CloneNotSupportedException, IOException, ClassNotFoundException {
//        序列化
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
//        获取对象输出流
        ObjectOutputStream oos = new ObjectOutputStream(bos);
//        将当前的对象
        oos.writeObject(this);

//        反序列化
        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()));
        Object obj = ois.readObject();
        return obj;
    }
}


二、JSP

1.九大内置对象

标签库:c标签

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

2.指令:

page:设置编码集

taglib:导入标签库

include:包含界面

动态包含

<jsp:include page=""></jsp:include>

静态包含

<%@include file="common.jsp" %>


三.servlet


    是什么?运行在服务端的程序
    怎么用?


    1.  extends HttpServlet


        配置映射①web.xml ②@webservlet("/demo")
        实现方法:doget/dopost



   2. 生命周期?


        初始化:init
        服务:service
        销毁:destroy



   3.doget/dopost


        对应处理get/post请求
    request的常用方法
        setcharsetencoding()
        getparameter()
        getsession
        ....


    4.页面跳转:重定向与转发


        response.sendredirect();
        request.getrequestdispather.forword
        区别:
            转发:能够传递数据,并且地址栏不会发生变化
            重定向:不能传递数据,地址栏会变化

public class DemoServlet extends HttpServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    super.doGet(req, resp);
}


@Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    System.out.println("come in....");
        super.doPost(req, resp);
        req.setAttribute("name","sa");
        req.getRequestDispatcher("a.jsp").forward(req, resp);
}


}


 



   5. 四大作用域:


        pagecontext,request,session,application
    session与cookie的区别
        session:服务端
        cookie:客户端
            相同:都可以保存数据
            不同:
                服务端:安全性高,占用大量的服务器资源;
                客户端:安全性低,占用少量内存;cookie存储数量是有限的;


四.Spring


    1.ioc:
        控制反转、依赖注入
        由原来程序员手段创建对象的权利,转交给Spring容器;
        优点:代码的维护性提高了


    2.aop:
        面向切面
        代理=目标+通知
        将核心业务与非核心分离,使程序员将精力都放在核心业务中;
        
        定义切面:* *..*.*service.*del(..)
        定义通知:@around
    
  3. 注入的方式:
        set注入
        构造注入:
        自动装配:byname,bytype
            @autowised @resource

SpringMVC

Mybatis


总结

提示:多记多练

例如:以上就是今天要讲的内容,本文仅仅简单介绍了java的基础

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值