当前位置:网站首页>模拟Servlet的本质
模拟Servlet的本质
2022-07-07 14:15:00 【Vayne的胖虎子】
项目的目录结构
---src
---web.properties
---javax.servlet
---Servlet
---web
---Tomcat
---service
---UserListServlet
---UserLoginServlet
- web.properties
/aaa=service.UserListServlet
/bbb=service.UserLoginServlet
- Servlet
package javax.servlet;
/** * Author:LinYue * Time:2022-06-27 10:29:54 */
public interface Servlet {
void service();
}
- Tomcat
package web;
import javax.servlet.Servlet;
import java.util.ResourceBundle;
import java.util.Scanner;
/** * Author:LinYue * Time:2022-06-27 10:32:13 */
public class Tomcat {
public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
System.out.println("Tomcat启动了....");
Scanner s = new Scanner(System.in);
System.out.print("请输入访问路径:");
String path = s.nextLine();
ResourceBundle bundle = ResourceBundle.getBundle("web");
String resource = bundle.getString(path);
Class clazz = Class.forName(resource);
Object obj = clazz.newInstance();
Servlet servlet = (Servlet) obj;
servlet.service();
}
}
- UserListServlet
package service;
import javax.servlet.Servlet;
/** * Author:LinYue * Time:2022-06-27 10:31:06 */
public class UserListServlet implements Servlet {
@Override
public void service() {
System.out.println("UserListServlet的service方法调用了!");
}
}
- UserLoginServlet
package service;
import javax.servlet.Servlet;
/** * Author:LinYue * Time:2022-06-27 10:31:06 */
public class UserLoginServlet implements Servlet {
@Override
public void service() {
System.out.println("UserLoginServlet的service方法调用了!");
}
}
边栏推荐
- laravel中将session由文件保存改为数据库保存
- [summary of knowledge] summary of notes on using SVN in PHP
- Communication mode between application program and MATLAB
- How can laravel get the public path
- 融云斩获 2022 中国信创数字化办公门户卓越产品奖!
- 谈谈 SAP iRPA Studio 创建的本地项目的云端部署问题
- 无法将“pip”项识别为 cmdlet、函数、脚本文件或可运行程序的名称
- Introduction to ThinkPHP URL routing
- What else can an ordinary person do besides working in a factory to make money?
- 47_Opencv中的轮廓查找 cv::findContours()
猜你喜欢

深度之眼(七)——矩阵的初等变换(附:数模一些模型的解释)

Unity3D_ Class fishing project, control the distance between collision walls to adapt to different models

Rongyun won the 2022 China Xinchuang digital office portal excellence product award!

AE learning 02: timeline

What are compiled languages and interpreted languages?

Apache Doris刚“毕业”:为什么应关注这种SQL数据仓库?

强化实时数据管理,英方软件助力医保平台安全建设

分步式監控平臺zabbix

华东师大团队提出,具有DNA调控电路的卷积神经网络的系统分子实现

Odoo integrated plausible embedded code monitoring platform
随机推荐
laravel post提交数据时显示异常
ThinkPHP URL 路由简介
Numpy -- epidemic data analysis case
47_Opencv中的轮廓查找 cv::findContours()
分步式監控平臺zabbix
Laravel 服务提供者实例教程 —— 创建 Service Provider 测试实例
华东师大团队提出,具有DNA调控电路的卷积神经网络的系统分子实现
PHP实现执行定时任务的几种思路详解
Vs tool word highlight with margin
深度之眼(七)——矩阵的初等变换(附:数模一些模型的解释)
星瑞格数据库入围“2021年度福建省信息技术应用创新典型解决方案”
The unity vector rotates at a point
一个普通人除了去工厂上班赚钱,还能干什么工作?
95. (cesium chapter) cesium dynamic monomer-3d building (building)
PHP realizes wechat applet face recognition and face brushing login function
Apache Doris刚“毕业”:为什么应关注这种SQL数据仓库?
Xcode Revoke certificate
统计学习方法——感知机
What else can an ordinary person do besides working in a factory to make money?
Step by step monitoring platform ZABBIX