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方法!");
        }
    
    }

     

    最终效果:

     

    不一样的烟火
  • 相关阅读:
    英语----非谓语动词to do
    英语----非谓语动词done
    英语----三大从句的混合实战
    英语----状语从句连接词(下)
    英语----状语从句连接词(中)
    英语----状语从句连接词(上)
    xcode7.3遇到的问题
    UIScrollView AutoLayout
    cocoapods 卸载  &  安装
    iOS即时通讯之CocoaAsyncSocket源码解析五
  • 原文地址:https://www.cnblogs.com/cstdio1/p/11647005.html
Copyright © 2011-2022 走看看