当前位置: 首页 > news >正文

Spring整合SpringMVC

目录

【pom.xml】文件;

新建【applicationContext.xml】文件

新建【springmvc.xml】文件;

配置【src/main/webapp/WEB-INF/web.xml】文件;

新建【com.gupaoedu.service.IUserService】;

新建【com.gupaoedu.service.impl.UserServiceImpl】;

新建【com.gupaoedu.controller.UserController】;


pom.xml文件;

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.gupaoedu</groupId><artifactId>springmvc_demo_03</artifactId><version>1.0-SNAPSHOT</version><packaging>war</packaging><name>springmvc_demo_03 Maven Webapp</name><!-- FIXME change it to the project's website --><url>http://www.example.com</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><maven.compiler.source>1.7</maven.compiler.source><maven.compiler.target>1.7</maven.compiler.target></properties><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.11</version><scope>test</scope></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>4.3.1.RELEASE</version></dependency></dependencies><build><finalName>springmvc_demo_03</finalName><pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --><plugins><plugin><artifactId>maven-clean-plugin</artifactId><version>3.1.0</version></plugin><!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging --><plugin><artifactId>maven-resources-plugin</artifactId><version>3.0.2</version></plugin><plugin><artifactId>maven-compiler-plugin</artifactId><version>3.8.0</version></plugin><plugin><artifactId>maven-surefire-plugin</artifactId><version>2.22.1</version></plugin><plugin><artifactId>maven-war-plugin</artifactId><version>3.2.2</version></plugin><plugin><artifactId>maven-install-plugin</artifactId><version>2.5.2</version></plugin><plugin><artifactId>maven-deploy-plugin</artifactId><version>2.8.2</version></plugin></plugins></pluginManagement><plugins><plugin><groupId>org.apache.tomcat.maven</groupId><artifactId>tomcat7-maven-plugin</artifactId><version>2.2</version><configuration><port>8080</port> <!-- 访问端口 --><path>/</path>    <!-- 访问路径 --></configuration></plugin></plugins></build>
</project>

新建【applicationContext.xml】文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"><!-- 添加扫描 --><context:component-scan base-package="com.gupao.edu" use-default-filters="true"><context:exclude-filter type="annotation"expression="org.springframework.stereotype.Controller"/></context:component-scan>
</beans>

新建【springmvc.xml】文件;

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"><!-- 添加扫描 --><context:component-scan base-package="com.gupao.edu"use-default-filters="false"><context:include-filter type="annotation"expression="org.springframework.stereotype.Controller"/></context:component-scan><!-- 开启注解--><mvc:annotation-driven/>
</beans>

配置【src/main/webapp/WEB-INF/web.xml】文件;

<!DOCTYPE web-app PUBLIC"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN""http://java.sun.com/dtd/web-app_2_3.dtd" ><web-app><display-name>Archetype Created Web Application</display-name><!-- 配置Spring --><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext.xml</param-value></context-param><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><!-- 配置SpringMVC --><servlet><servlet-name>springmvc</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><!-- 关联SpringMVC的配置文件 --><init-param><param-name>contextConfigLocation</param-name><param-value>classpath:springmvc.xml</param-value></init-param></servlet><servlet-mapping><servlet-name>springmvc</servlet-name><url-pattern>/</url-pattern></servlet-mapping>
</web-app>

新建【com.gupaoedu.service.IUserService】;

package com.gupaoedu.service;public interface IUserService {public String hello();}

新建【com.gupaoedu.service.impl.UserServiceImpl】;


import com.gupaoedu.service.IUserService;
import org.springframework.stereotype.Service;@Service
public class UserServiceImpl implements IUserService {@Overridepublic String hello() {return "hello Service ... ... ";}
}

新建【com.gupaoedu.controller.UserController】;

package com.gupaoedu.controller;import com.gupaoedu.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
public class UserController {@Autowiredprivate IUserService userService;@GetMapping("/user/hello")public String hello() {return userService.hello();}}

相关文章:

Spring整合SpringMVC

目录 【pom.xml】文件&#xff1b; 新建【applicationContext.xml】文件 新建【springmvc.xml】文件&#xff1b; 配置【src/main/webapp/WEB-INF/web.xml】文件&#xff1b; 新建【com.gupaoedu.service.IUserService】&#xff1b; 新建【com.gupaoedu.service.impl.Use…...

【Rust自学】10.4. trait Pt.2:trait作为参数和返回类型、trait bound

喜欢的话别忘了点赞、收藏加关注哦&#xff0c;对接下来的教程有兴趣的可以关注专栏。谢谢喵&#xff01;(&#xff65;ω&#xff65;) 说句题外话&#xff0c;写这篇的时间比写所有权还还花的久&#xff0c;trait是真的比较难理解的概念。 10.4.1. 把trait作为参数 继续以…...

嵌入式系统 (2.嵌入式硬件系统基础)

2.嵌入式硬件系统基础 2.1嵌入式硬件系统的组成 嵌入式硬件系统以嵌入式微处理器为核心&#xff0c;主要由嵌入式微处理器、总线、存储器、输入/输出接口和设备组成。 嵌入式微处理器 嵌入式微处理器采用冯诺依曼结构或哈佛结构&#xff1a;前者指令和数据共享同一存储空间…...

Linux 下 Vim 环境安装踩坑问题汇总及解决方法(重置版)

导航 安装教程导航 Mamba 及 Vim 安装问题参看本人博客&#xff1a;Mamba 环境安装踩坑问题汇总及解决方法&#xff08;初版&#xff09;Linux 下Mamba 及 Vim 安装问题参看本人博客&#xff1a;Mamba 环境安装踩坑问题汇总及解决方法&#xff08;重置版&#xff09;Windows …...

OpenAI 故障复盘 - 阿里云容器服务与可观测产品如何保障大规模 K8s 集群稳定性

本文作者&#xff1a; 容器服务团队&#xff1a;刘佳旭、冯诗淳 可观测团队&#xff1a;竺夏栋、麻嘉豪、隋吉智 一、前言 Kubernetes(K8s)架构已经是当今 IT 架构的主流与事实标准&#xff08;CNCF Survey[1]&#xff09;。随着承接的业务规模越来越大&#xff0c;用户也在使…...

安卓触摸对焦

1. 相机坐标说明 触摸对焦需要通过setFocusAreas()设置对焦区域&#xff0c;而该方法的参数的坐标&#xff0c;与屏幕坐标并不相同&#xff0c;需要做一个转换。 对Camera&#xff08;旧版相机API&#xff09;来说&#xff0c;相机的坐标区域是一个2000*2000&#xff0c;原点…...

jupyter出现“.ipynb appears to have died. It will restart automatically.”解决方法

原因 解决方法&#xff1a;更新jupyter的版本 1.打开anaconda prompt 2、更新jupyter版本 在anaconda prompt输入以下指令 conda update jupyter如图&#xff1a;...

20250108-实验+神经网络

实验3. 神经网络与反向传播算法 3.1 计算图&#xff1a;复合函数的计算图 实验要求1&#xff1a;基于numpy实现 ( y 1 , y 2 ) f ( x 1 , x 2 , x 3 ) (y_1,y_2) f(x_1,x_2,x_3) (y1​,y2​)f(x1​,x2​,x3​) 的反向传播算法&#xff08;不允许使用自动微分&#xff09;&a…...

【权限管理】CAS(Central Authentication Service)

CAS&#xff08;Central Authentication Service&#xff09;是一种广泛应用的 单点登录&#xff08;SSO&#xff09; 协议&#xff0c;它允许用户在一个集中式的身份验证系统中登录一次后&#xff0c;便可以无缝访问多个应用系统&#xff0c;而无需重复登录。CAS 通过统一的身…...

Golang笔记:使用net包进行TCP监听回环测试

文章目录 前言TCP监听回环代码演示 附&#xff1a;UDP监听回环 前言 TCP是比较基础常用的网络通讯方式&#xff0c;这篇文章将使用Go语言实现TCP监听回环测试。 本文中使用 Packet Sender 工具进行测试&#xff0c;其官网地址如下&#xff1a; https://packetsender.com/ TC…...

《浮岛风云》V1.0中文学习版

《浮岛风云》中文版https://pan.xunlei.com/s/VODadt0vSGdbrVOBEsW9Xx8iA1?pwdy7c3# 一款有着类似暗黑破坏神的战斗系统、类似最终幻想的奇幻世界和100%可破坏体素环境的动作冒险RPG。...

Day10——爬虫

爬虫概念 网络请求 爬虫分类 基本流程 请求头...

10. C语言 函数详解

本章目录: 前言1. C 语言函数概述1.1 函数的定义与结构1.2 函数声明1.3 函数调用 2. 函数参数传递2.1 传值调用2.2 传引用调用&#xff08;模拟&#xff09;2.3 引用调用&#xff08;C 特性&#xff09; 3. 内部函数与外部函数3.1 内部函数3.2 外部函数3.3 示例&#xff1a;多个…...

NRC优先级中比较特殊的—NRC0x13和NRC0x31

1、基础知识 大家都了解 NRC0x13&#xff0c;表示长度错误和格式错误 NRC0x31&#xff0c;表示DID不支持和数据格式不支持 2、为什么说这两个NRC比较特殊 看下图的标注部分&#xff1a; 2.1、先看NRC0x13 步骤一&#xff1a;仔细看是先判断Minmun Length Check &#xff0…...

ref() 和 reactive() 区别

ref() 和 reactive() 都是 Vue 3 中用于创建响应式数据的方法&#xff0c;但它们之间存在一些关键差异。 首先&#xff0c;ref() 用于创建响应式的标量值&#xff0c;比如数字、字符串、布尔值等基本数据类型&#xff0c;以及对象和数组等复杂数据类型。当你使用 ref() 时&…...

深度学习与计算机视觉 (博士)

文章目录 零、计算机视觉概述一、深度学习相关概念1.学习率η2.batchsize和epoch3.端到端(End-to-End)、序列到序列(Seq-to-Seq)4.消融实验5.学习方式6.监督学习的方式(1)有监督学习(2)强监督学习(3)弱监督学习(4)半监督学习(5)自监督学习(6)无监督学习(7)总结&#xff1a;不同…...

Sprint Boot教程之五十:Spring Boot JpaRepository 示例

Spring Boot JpaRepository 示例 Spring Boot建立在 Spring 之上&#xff0c;包含 Spring 的所有功能。由于其快速的生产就绪环境&#xff0c;使开发人员能够直接专注于逻辑&#xff0c;而不必费力配置和设置&#xff0c;因此如今它正成为开发人员的最爱。Spring Boot 是一个基…...

NaVILA:用于足式机器人导航的VLA模型

论文地址&#xff1a;https://navila-bot.github.io/static/navila_paper.pdf 项目地址&#xff1a;https://navila-bot.github.io/ 本文提出了一种名为NaVILA的机器人导航模型&#xff0c;旨在解决视觉语言导航问题&#xff0c;并允许机器人在更具挑战性和杂乱的场景中进行导…...

大语言模型提示技巧(七)-扩展

扩展是将较短的文本&#xff0c;例如一组提示或主题列表&#xff0c;输入到大型语言模型中&#xff0c;让模型生成更长的文本。我们可以利用这个特性让大语言模型生成基于某个主题的电子邮件或小论文。通过这种方式使用大语言模型&#xff0c;可以为工作与生活提供诸多便利&…...

基类指针指向派生类对象,基类指针的首地址永远指向子类从基类继承的基类首地址

文章目录 基类指针指向派生类对象&#xff0c;基类指针的首地址永远指向子类从基类继承的基类起始地址。代码代码2 基类指针指向派生类对象&#xff0c;基类指针的首地址永远指向子类从基类继承的基类起始地址。 代码 #include <iostream> using namespace std;class b…...

观成科技:隐蔽隧道工具Ligolo-ng加密流量分析

1.工具介绍 Ligolo-ng是一款由go编写的高效隧道工具&#xff0c;该工具基于TUN接口实现其功能&#xff0c;利用反向TCP/TLS连接建立一条隐蔽的通信信道&#xff0c;支持使用Let’s Encrypt自动生成证书。Ligolo-ng的通信隐蔽性体现在其支持多种连接方式&#xff0c;适应复杂网…...

连锁超市冷库节能解决方案:如何实现超市降本增效

在连锁超市冷库运营中&#xff0c;高能耗、设备损耗快、人工管理低效等问题长期困扰企业。御控冷库节能解决方案通过智能控制化霜、按需化霜、实时监控、故障诊断、自动预警、远程控制开关六大核心技术&#xff0c;实现年省电费15%-60%&#xff0c;且不改动原有装备、安装快捷、…...

将对透视变换后的图像使用Otsu进行阈值化,来分离黑色和白色像素。这句话中的Otsu是什么意思?

Otsu 是一种自动阈值化方法&#xff0c;用于将图像分割为前景和背景。它通过最小化图像的类内方差或等价地最大化类间方差来选择最佳阈值。这种方法特别适用于图像的二值化处理&#xff0c;能够自动确定一个阈值&#xff0c;将图像中的像素分为黑色和白色两类。 Otsu 方法的原…...

04-初识css

一、css样式引入 1.1.内部样式 <div style"width: 100px;"></div>1.2.外部样式 1.2.1.外部样式1 <style>.aa {width: 100px;} </style> <div class"aa"></div>1.2.2.外部样式2 <!-- rel内表面引入的是style样…...

【C语言练习】080. 使用C语言实现简单的数据库操作

080. 使用C语言实现简单的数据库操作 080. 使用C语言实现简单的数据库操作使用原生APIODBC接口第三方库ORM框架文件模拟1. 安装SQLite2. 示例代码:使用SQLite创建数据库、表和插入数据3. 编译和运行4. 示例运行输出:5. 注意事项6. 总结080. 使用C语言实现简单的数据库操作 在…...

Unit 1 深度强化学习简介

Deep RL Course ——Unit 1 Introduction 从理论和实践层面深入学习深度强化学习。学会使用知名的深度强化学习库&#xff0c;例如 Stable Baselines3、RL Baselines3 Zoo、Sample Factory 和 CleanRL。在独特的环境中训练智能体&#xff0c;比如 SnowballFight、Huggy the Do…...

浅谈不同二分算法的查找情况

二分算法原理比较简单&#xff0c;但是实际的算法模板却有很多&#xff0c;这一切都源于二分查找问题中的复杂情况和二分算法的边界处理&#xff0c;以下是博主对一些二分算法查找的情况分析。 需要说明的是&#xff0c;以下二分算法都是基于有序序列为升序有序的情况&#xf…...

Maven 概述、安装、配置、仓库、私服详解

目录 1、Maven 概述 1.1 Maven 的定义 1.2 Maven 解决的问题 1.3 Maven 的核心特性与优势 2、Maven 安装 2.1 下载 Maven 2.2 安装配置 Maven 2.3 测试安装 2.4 修改 Maven 本地仓库的默认路径 3、Maven 配置 3.1 配置本地仓库 3.2 配置 JDK 3.3 IDEA 配置本地 Ma…...

管理学院权限管理系统开发总结

文章目录 &#x1f393; 管理学院权限管理系统开发总结 - 现代化Web应用实践之路&#x1f4dd; 项目概述&#x1f3d7;️ 技术架构设计后端技术栈前端技术栈 &#x1f4a1; 核心功能特性1. 用户管理模块2. 权限管理系统3. 统计报表功能4. 用户体验优化 &#x1f5c4;️ 数据库设…...

技术栈RabbitMq的介绍和使用

目录 1. 什么是消息队列&#xff1f;2. 消息队列的优点3. RabbitMQ 消息队列概述4. RabbitMQ 安装5. Exchange 四种类型5.1 direct 精准匹配5.2 fanout 广播5.3 topic 正则匹配 6. RabbitMQ 队列模式6.1 简单队列模式6.2 工作队列模式6.3 发布/订阅模式6.4 路由模式6.5 主题模式…...