zoukankan      html  css  js  c++  java
  • Servlet简单的登陆窗口

    web.xml配置:

    jsp代码:

    注意action书写的是为这次登陆做处理类的别名,method就是请求的方式

     Get请求方式没有请求实体

    //如果只是看效果就光写一下service方法就行了
    
    package com.zyb.test;
    
    import java.io.IOException;
    
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import com.sun.java_cup.internal.runtime.Symbol;
    
    public class TestServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.getWriter().write("test file");//打印在页面上
        System.out.println("test file");//打印在控制台
        
        
    }
    @Override
        public void init() throws ServletException {
        
            System.out.println("Servlet初始化完成!");
        }
    
    public void destory() {
        
        System.out.println("Servlet销毁完成!");
    }
    
    
    @Override
        protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("我是doPost方法!");
        }
    @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("我是doGet方法!");
        }
    
    }

     

    最终效果:

     

    不一样的烟火
  • 相关阅读:
    jwt手动生成access_token
    python学习-52 XML模块
    python学习-51 shelve模块
    python学习-50 pickle模块
    python学习-49 json模块
    python学习-48 模块2
    python学习-47 random模块
    python学习-46 时间模块
    python学习-45 模块
    python学习-44 程序的解耦 (不是特别懂的,回头在复习)
  • 原文地址:https://www.cnblogs.com/cstdio1/p/11647005.html
Copyright © 2011-2022 走看看