springboot整合servlert
SpringBoot 整合
2023-09-27 14:22:13 时间
一springboot整合servlet
1.1 工程结构
1.2 pom文件的配置
<!--spring boot的启动类 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
1.3 servlet文件
package com.ljf.spring.boot.demo.servlet.controller;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
*SpringBoot整合Servlet方式一
*
*<servlet>
* <servlet-name>LoginServlet</servlet-name>
* <servlet-class>com.ljf.spring.boot.demo.servlet.controller.LoginServlet</servlet-class>
*</servlet>
*
*<servlet-mapping>
* <servlet-name>LoginServlet</servlet-name>
* <url-pattern>/login</url-pattern>
*</servlet-mapping>
*
*/
@WebServlet(name="LoginServlet",urlPatterns="/login") //此注解和在web.xml配置的servlet一样,如上面
public class LoginServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("FirstServlet............");
//return "我的第一个first";
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
this.doGet(req, resp);
}
}
1.4 启动类
1.5 访问结果
相关文章
- SpringBoot 集成JUnit
- springboot 项目基本目录包结构
- springboot整合redis解决订单重复请求的问题
- 微服务技术系列教程(46)-SpringBoot整合MongoDB(文章评论案例)
- 微服务技术系列教程(03) - SpringBoot - 整合各种数据源(JdbcTemplate、MyBatis、JPA)
- 分布式系列教程(03) -分布式Redis缓存(SpringBoot整合Redis)
- SpringBoot与MybatisPlus3.X整合示例(十六)
- springboot配置mybatis
- springboot(九):定时任务
- 基于Java(SpringBoot)+Vue+MySQL 实现(Web)的网络课程平台【100010329】
- 基于Java(SSM+SpringBoot+Thymeleaf)+MySQL 开发的论坛社区网站【100010072】
- 一小时学会使用Springboot整合沙箱环境支付宝支付(附源码)
- springboot 整合swagger入门案例
- Linux环境下ElasticSearch的安装与使用(SpringBoot整合云服务器上的ElasticSearch)
- springboot + mybatis +easyUI整合案例
- springboot知识点总结
- SpringBoot中使用Spring profile进行配置【谨慎使用,参见SpringBoot 2.4.0发布文档】
- SpringBoot+Mybaits搭建通用管理系统实例一:项目规划及框架搭建
- SpringBoot入门十二(整合之项目打包部署运行)
- SpringBoot入门五(整合之端口和静态资源)
- 基于SpringBoot的分布式事务LCN整合分享
- SpringBoot 与Shiro 整合系列(五)会话管理
- 让我们大声说:HelloSpringBoot(“最易懂得SpringBoot学习”)
- SpringBoot应用整合并使用Docker安装ELK实现日志收集
- SpringBoot整合ElasticSearch(最终更)
- SpringBoot整合ElasticSearch(第八更)
- 【第三期】电商分布式前沿springboot接口服务之删除和更新-Array-专题视频课程...