zoukankan      html  css  js  c++  java
  • 03007_HttpServlet

    1、创建

        new---Servlet

      

      

      

      

     1 package com.gzdlh.servlet;
     2 
     3 import java.io.IOException;
     4 import javax.servlet.ServletException;
     5 import javax.servlet.http.HttpServlet;
     6 import javax.servlet.http.HttpServletRequest;
     7 import javax.servlet.http.HttpServletResponse;
     8 
     9 public class QuickStartServlet2 extends HttpServlet {
    10 
    11     protected void doGet(HttpServletRequest request, HttpServletResponse response)
    12             throws ServletException, IOException {
    13         response.getWriter().append("Served at: ").append(request.getContextPath());
    14     }
    15 
    16     protected void doPost(HttpServletRequest request, HttpServletResponse response)
    17             throws ServletException, IOException {
    18         doGet(request, response);
    19     }
    20 
    21 }

    2、如果提示:servlet名字已经存在,很常见的一种情况是:你开始建了一个这样名字的servlet然后你删除了这个java文件,但是根据servlet2.5规范,web.xml里面存有这个servlet的映射关系,但是删除的时候,ide并不智能它没有把web.xml里面的映射关系删除,需要自己手动删除。

    3、修改Servlet模板

      

      

      

  • 相关阅读:
    算法
    Unity-UI
    lua-设计与实现 1类型
    Unity-Cache Server
    lua-高效编程-总结
    算法-JPS寻路设计思想
    数据结构- List、Dictionary
    数据结构-二叉树、堆
    VSCode更好用
    功能快捷键
  • 原文地址:https://www.cnblogs.com/gzdlh/p/8201824.html
Copyright © 2011-2022 走看看