zoukankan      html  css  js  c++  java
  • servlet的xml配置详解

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
             version="4.0">
     
        <servlet>
            <!--自定义,一般为类名-->
            <servlet-name>servletDemo1</servlet-name>
            <!--一定是package + .类名-->
            <servlet-class>day08_servlet.ServletDemo1</servlet-class>
        </servlet>
        <!--给Servlet提供(映射)一个可供客户端访问的URI-->
        <servlet-mapping>
            <!--和servlet中的name必须相同-->
            <servlet-name>servletDemo1</servlet-name>
            <!-- servlet的映射路径 -->
            <url-pattern>/servlet</url-pattern>
        </servlet-mapping>
       
    </web-app>

    这里要注意的是servlet-mapping的url-pattern中的这个映射路径 / 一定不能忘记!!!

    配置完成后,启动tomcat服务器,然后在浏览器中输入http://localhost:8080/servlet即可。

    与其战胜敌人一万次,不如战胜自己一次。
  • 相关阅读:
    Android px,dp,pt,sp的差别
    C 八皇后
    线性表
    android 推断手机是否支持前置摄像头
    C/C++易错难点笔记01
    Java日志记录的5条规则
    hdoj-1312-Red and Black
    oracle 11g sql developer安装后无法使用
    显示指定时间的秒数
    云端自动化测试方案
  • 原文地址:https://www.cnblogs.com/hyjh/p/11837711.html
Copyright © 2011-2022 走看看