zoukankan      html  css  js  c++  java
  • 关于servlet的配置

    当我们使用eclipse新建一个Servlet时,我们到web.xml中配置后有时会出现服务器无法启动的情况

    下面我们来看:

    eg:

    servlet:

    **
     * Servlet implementation class LogoServlet
     */
    @WebServlet("/LogoServlet")//重点在这里
    public class LogoServlet extends HttpServlet {
     private static final long serialVersionUID = 1L;

     
     public LogoServlet() {
     
     }
     protected void doGet(HttpServletRequest request, HttpServletResponse response)
       throws ServletException, IOException {
      this.doPost(request, response);
     }
     protected void doPost(HttpServletRequest request, HttpServletResponse response)
       throws ServletException, IOException {
     
     }

    }

    当我们去web.xml中配置了一个与@WebServlet("/LogoServlet相同的servlet后那么服务器就无法启动了,

    因为:

    eclipse自动帮我生成了注解,servlet3.0支持注解,那么问题就来了,你们是双胞胎,我到底该用哪一个呢,

    好吧你们是双胞胎,那我得静静的考虑下,所以就不启动服务器咯。

    因此

    方法一:我们只需不使用注解,获取不去配置web.xml就可以了。

    方法二:改变二者的任意一个名就可以啦。

     原创,不对之处请指正。邮箱:jleeci@foxmail.com

  • 相关阅读:
    sql行列互转
    用户角色权限设计思路
    树节点类型数据的Datatable转Json
    [C#]最简单的Base64加密解密
    WEB打印控件Lodop(V6.x)使用说明及样例
    js代码 设为首页 加入收藏
    Json字符转化成对象
    C++函数返回值为const
    7.双指针(two pointer)
    线程同步与锁
  • 原文地址:https://www.cnblogs.com/JLeeci/p/5599171.html
Copyright © 2011-2022 走看看