博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Servlet的入门案例
阅读量:4452 次
发布时间:2019-06-07

本文共 1158 字,大约阅读时间需要 3 分钟。

 


编写入门案例

1)编写java类,继承HttpServlet类

  2)重新doGet和doPost方法

3)Servlet程序交给tomcat服务器运行!!

   3.1 servlet程序的class码拷贝到WEB-INF/classes目录

   3.2 在web.xml文件中进行配置

 

package com.loaderman.demo;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.io.IOException;public class TestServlet extends HttpServlet {    @Override    protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {        //向浏览器输出内容        response.getWriter().write("this is first servlet!");    }    @Override    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {        this.doGet(req, resp);    }}

 


mTestServlet
com.loaderman.demo.TestServlet
mTestServlet
/demotest

 

转载于:https://www.cnblogs.com/loaderman/p/6415466.html

你可能感兴趣的文章
SDWebImage 新版接口使用方法
查看>>
简单的jQuery检测注册用户名
查看>>
DataTable导出为word,excel,html,csv,pdf,.txt
查看>>
android ListView详解
查看>>
软件工程 第一次作业
查看>>
Content Server HA搭建
查看>>
vue-textarea 自适应高度
查看>>
(2)数据结构——线性表(链表)实现
查看>>
[leetCode]Linked List Cycle I+II
查看>>
leetcode中的python学习
查看>>
sqlserver打开对象资源管理器管理的帮助文档的快捷键
查看>>
JBOSSAS 5.x/6.x 反序列化命令执行漏洞(CVE-2017-12149)
查看>>
Zookeeper zkui-zookeeper图形化管理工具
查看>>
java运行时内存分类
查看>>
为什么说 Git 比 SVN 更好
查看>>
1.基础数据类型的初识 字符串 bool 整型 if else elif
查看>>
【设计模式】4、原型模式
查看>>
进入meta模式关闭背光灯
查看>>
webstorm上svn的安装使用
查看>>
【JEECG技术文档】数据权限自定义SQL表达式用法说明
查看>>