利用RequestMappingHandlerMapping提取Spring MVC @RequestMapping

Spring MVC 映射注入类继承结构

image

其中getHandlerMethods能够获取所有处理方法和映射,代码如下:
    /**
     * Return a map with all handler methods and their mappings.
     */
    public Map<T, HandlerMethod> getHandlerMethods() {
        return Collections.unmodifiableMap(this.handlerMethods);
    }
如果能够获得RequestMappingInfoHaddlerMapping Bean实例,就能通过getHandlerMethods()方法得到使用Spring MVC注解的处理方法和映射对象RequestMappingInfo
RequestMappingInfo存储中所有Handler的配置信息。
使用@Configuration注解配置Bean,获取RequestMappingHandlerMapping
package com.zokapper.configration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

@Configuration
public class RequestMappingHandlerConfig{
    @Bean
    public RequestMappingHandlerMapping requestMappingHandlerMapping() {
        RequestMappingHandlerMapping mapping = new RequestMappingHandlerMapping();
        return mapping;
    }
}
编写测试类测试
package com.zokapper.configuration;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

import com.zokapper.configuration.RequestMappingHandlerConfig;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {  "classpath:applicationContext-[MVC].xml","classpath:applicationContext.xml"})
public class RequestMappingHandlerConfigTest {

    @Autowired
    RequestMappingHandlerConfig requestMappingHandlerConfig;

    //Spring MVC 提取注解中URL映射
    @Test
    public void detectHandlerMethods(){
        final RequestMappingHandlerMapping requestMappingHandlerMapping = requestMappingHandlerConfig.requestMappingHandlerMapping ();
        Map<RequestMappingInfo, HandlerMethod> map = requestMappingHandlerMapping.getHandlerMethods();

        Set<RequestMappingInfo> mappings = map.keySet();
        Map<String, String> reversedMap = new HashMap<String, String>();
        for(RequestMappingInfo info : mappings) {
            HandlerMethod method = map.get(info);
            System.out.println (method.toString()+"===>"+info.getPatternsCondition().toString());
        }
    }
}
6/2025 MP4 出版 |视频: h264, 1280x720 |音频:AAC,44.1 KHz,2 Ch 语言:英语 |持续时间:12h 3m |大小: 4.5 GB 通过实际 NLP 项目学习文本预处理、矢量化、神经网络、CNN、RNN 和深度学习 学习内容 学习核心 NLP 任务,如词汇切分、词干提取、词形还原、POS 标记和实体识别,以实现有效的文本预处理。 使用 One-Hot、TF-IDF、BOW、N-grams 和 Word2Vec 将文本转换为向量,用于 ML 和 DL 模型。 了解并实施神经网络,包括感知器、ANN 和数学反向传播。 掌握深度学习概念,如激活函数、损失函数和优化技术,如 SGD 和 Adam 使用 CNN 和 RNN 构建 NLP 和计算机视觉模型,以及真实数据集和端到端工作流程 岗位要求 基本的 Python 编程知识——包括变量、函数和循环,以及 NLP 和 DL 实现 熟悉高中数学——尤其是线性代数、概率和函数,用于理解神经网络和反向传播。 对 AI、ML 或数据科学感兴趣 – 不需要 NLP 或深度学习方面的经验;概念是从头开始教授的 描述 本课程专为渴望深入了解自然语言处理 (NLP) 和深度学习的激动人心的世界的人而设计,这是人工智能行业中增长最快和需求最旺盛的两个领域。无论您是学生、希望提升技能的在职专业人士,还是有抱负的数据科学家,本课程都能为您提供必要的工具和知识,以了解机器如何阅读、解释和学习人类语言。我们从 NLP 的基础开始,从头开始使用文本预处理技术,例如分词化、词干提取、词形还原、停用词删除、POS 标记和命名实体识别。这些技术对于准备非结构化文本数据至关重要,并用于聊天机器人、翻译器和推荐引擎等实际 AI 应用程序。接下来,您将学习如何使用 Bag of Words、TF-IDF、One-Hot E
内容概要:本文全面介绍了虚幻引擎4(UE4)的功能、应用场景、学习准备、基础操作、蓝图系统、材质与纹理、灯光与渲染等方面的内容。UE4是一款由Epic Games开发的强大游戏引擎,支持跨平台开发,广泛应用于游戏、虚拟现实、增强现实、建筑设计等领域。文章详细阐述了学习UE4前的硬件和软件准备,包括最低和推荐配置,以及Epic Games账户创建、启动器安装等步骤。接着介绍了UE4的界面组成和基本操作,如视口、内容浏览器、细节面板等。蓝图系统作为UE4的可视化脚本工具,极大降低了编程门槛,通过实例演练展示了蓝图的应用。材质与纹理部分讲解了材质编辑器的使用和纹理导入设置,灯光与渲染部分介绍了不同类型的灯光及其应用,以及后期处理和高质量图片渲染的方法。最后推荐了一些学习资源,包括官方文档、教程网站、论坛社区和书籍。 适合人群:对游戏开发感兴趣、希望学习UE4的初学者和有一定编程基础的研发人员。 使用场景及目标:①掌握UE4的基本操作和界面认知,为后续深入学习打下基础;②通过蓝图系统快速创建游戏逻辑,降低编程门槛;③学会材质与纹理的创建和设置,提升游戏画面的真实感;④掌握灯光与渲染技术,营造逼真的游戏氛围;⑤利用推荐的学习资源,加速UE4的学习进程。 阅读建议:本文内容详尽,涵盖了UE4的各个方面,建议读者按照章节顺序逐步学习,先从基础操作入手,再深入到蓝图、材质、灯光等高级功能。在学习过程中,结合实际项目进行练习,遇到问题时参考官方文档或社区论坛,不断积累经验和技能。
Vue.js 和 Leaflet 是两个流行的前端开发框架,Vue用于构建用户界面,而Leaflet是一个强大的JavaScript库,专用于创建交互式的地图应用。要在Vue项目中结合Leaflet实现图层控制,你可以按照以下步骤操作: 1. **安装依赖**:首先,在Vue项目中通过npm或yarn安装`vue-leaflet`插件,这将提供Leaflet组件的集成支持。例如: ```bash npm install vue-leaflet leaflet --save ``` 2. **引入并配置**:在你的Vue组件中导入`VueMap`组件,并在`<template>`中添加一个`<div>`来容纳地图: ```html <template> <div id="map" ref="map"></div> </template> ``` 3. **设置地图**: ```javascript <script> import { VueMap } from 'vue-leaflet'; export default { components: { VueMap }, data() { return { map: null, layers: [ // 初始化地图所需的图层列表 { name: '基础图层', layer: L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' }) } ] }; }, mounted() { this.map = new VueMap({ el: '#map', center: [51.505, -0.09], // 地理坐标 zoom: 13, layers: this.layers }); } }; </script> ``` 4. **图层控制**:在Vue中可以动态管理图层,比如添加、删除或者显示隐藏。你可以为每个图层设置一个开关,监听用户的操作来控制图层状态。 ```html <template> ... <button v-for="(layer, index) in layers" :key="index" @click="toggleLayer(layer.name)"> {{ layer.name }} </button> ... </template> <script> ... methods: { toggleLayer(name) { this.map.layers.eachLayer((layer) => { if (layer.options.name === name) { layer.setOpacity(!layer.getOpacity()); layer.setVisible(!layer.getVisible()); } }); } } ... </script> ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值