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

     

    最终效果:

     

    不一样的烟火
  • 相关阅读:
    fatal: protocol error: bad line length character: This
    httpd: apr_sockaddr_info_get() failed for bogon
    Go语言函数
    Go语言流程控制
    进制转换
    Go语言运算符
    LeetCode 62. Unique Paths
    LeetCode 61. Rotate List
    asdfasdfasdf
    开发者,别让自己孤独
  • 原文地址:https://www.cnblogs.com/cstdio1/p/11647005.html
Copyright © 2011-2022 走看看