当前位置:网站首页>模拟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方法调用了!");
}
}
边栏推荐
- 航天宏图信息中标乌鲁木齐某单位数据库系统研发项目
- iptables只允许指定ip地址访问指定端口
- 记一次项目的迁移过程
- Apache Doris刚“毕业”:为什么应关注这种SQL数据仓库?
- spark调优(三):持久化减少二次查询
- Enterprise log analysis system elk
- php 自带过滤和转义函数
- Odoo集成Plausible埋码监控平台
- Unity3D_ Class fishing project, control the distance between collision walls to adapt to different models
- Limit of total fields [1000] in index has been exceeded
猜你喜欢
Mysql database basic operation DQL basic query
2022 the 4th China (Jinan) International Smart elderly care industry exhibition, Shandong old age Expo
Notification uses full resolution
Good news! Kelan sundb database and Hongshu technology privacy data protection management software complete compatibility adaptation
Dotween -- ease function
过度依赖补助,大客户收款难,冲刺“国产数据库第一股”的达梦后劲有多足?
TiDB For PostgreSQL和YugabyteDB在Sysbench上的性能对比
HAVE FUN | “飞船计划”活动最新进展
Xcode Revoke certificate
Tragedy caused by deleting the console statement
随机推荐
Continuous creation depends on it!
华东师大团队提出,具有DNA调控电路的卷积神经网络的系统分子实现
Dotween -- ease function
Set the route and optimize the URL in thinkphp3.2.3
Rongyun won the 2022 China Xinchuang digital office portal excellence product award!
Limit of total fields [1000] in index has been exceeded
预测——灰色预测
Shader basic UV operations, translation, rotation, scaling
MySQL中, 如何查询某一天, 某一月, 某一年的数据
What is the difference between IP address and physical address
Is it reliable to open an account on Tongda letter with your mobile phone? Is there any potential safety hazard in such stock speculation
laravel构造函数和中间件执行顺序问题
What else can an ordinary person do besides working in a factory to make money?
Vs tool word highlight with margin
laravel中将session由文件保存改为数据库保存
three.js打造酷炫下雪效果
PyTorch 中的乘法:mul()、multiply()、matmul()、mm()、mv()、dot()
Plate - forme de surveillance par étapes zabbix
Excessive dependence on subsidies, difficult collection of key customers, and how strong is the potential to reach the dream of "the first share of domestic databases"?
Xcode Revoke certificate