SimpleUrlHandlerMapping

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"       xmlns:aop="http://www.springframework.org/schema/aop"       xmlns:context="http://www.springframework.org/schema/context"       xmlns:p="http://www.springframework.org/schema/p"       xmlns:mvc="http://www.springframework.org/schema/mvc"       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"       xsi:schemaLocation="       http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans.xsd       http://www.springframework.org/schema/aop  http://www.springframework.org/schema/aop/spring-aop.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">

<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">    <!--<property name="mappings"> <props>    <prop key="/hello.do">firstController</prop> </props> </property>-->    <property name="urlMap">    <map>    <entry value="firstController" key="/hello.do"/></map></property></bean>

<!--视图解析器-->    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">    <property name="prefix" value="/WEB-INF/"/>    <property name="suffix" value=".jsp"/>

</bean>

<bean class="Controller.FirstController" id="firstController"/></beans>
package Controller;import org.springframework.web.servlet.ModelAndView;import org.springframework.web.servlet.mvc.Controller;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;/** * Created by Administrator on 2017/8/14. */public class FirstController implements Controller{    public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {

ModelAndView mv=new ModelAndView();        //可以设置数据   数据放入该容器,可以在页面el表达式获取        mv.addObject("uname","Y2165就业对口专业100%");        //设置视图名称        mv.setViewName("index");        return mv;    }}
				
时间: 2024-08-09 10:42:46

SimpleUrlHandlerMapping的相关文章

&lt;mvc:default-servlet-handler/&gt;导致SimpleUrlHandlerMapping失效

整理springmvc的demo的时候遇到一件奇葩事情,本来就是想简单演示一下SimpleUrlHandlerMapping的用法就完活.结果写好demo怎么都无法进行映射,就好像根本就没有创建SimpleUrlHandlerMapping一样..关键配置文件如下: <!-- 容器默认的DefaultServletHandler处理 所有静态内容与无RequestMapping处理的URL--> <mvc:default-servlet-handler/> <bean id=

SimpleUrlHandlerMapping初始化

摘要: SimpleUrlHandlerMapping只是参与Handler的注册,请求映射时由AbstractUrlHandlerMapping搞定. 初始化时,通过setMappings(Properties mappings)或者setUrlMap(Map<String, ?> urlMap)设置映射关系,然后通过WebApplicationObjectSupport的initApplicationContext调用registerHandlers进行注册. 覆写initApplicat

Spring MVC:使用SimpleUrlHandlerMapping的一个简单例子

实现一个控制器ShirdrnController,如下所示: package org.shirdrn.spring.mvc; import java.util.Date; import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log;import org.apache.commons.logging.

springMVC笔记(二)- SimpleUrlHandlerMapping

SpringMVC里面有许多HandlerMapping,对这块还不太了解,所以决定了解一下这些东东的作用. 先来看第一个:org.springframework.web.servlet.handler.SimpleUrlHandlerMapping 官方的api文档解释如下: Implementation of the org.springframework.web.servlet.HandlerMapping interface to map from URLs to request han

Springmvc借助SimpleUrlHandlerMapping实现接口开关功能

一.接口开关功能 1.可配置化,依赖配置中心 2.接口访问权限可控 3.springmvc不会扫描到,即不会直接的将接口暴露出去 二.接口开关使用场景 和业务没什么关系,主要方便查询系统中的一些状态信息.比如系统的配置信息,中间件的状态信息.这就需要写一些特定的接口,不能对外直接暴露出去(即不能被springmvc扫描到,不能被swagger扫描到). 三.SimpleUrlHandlerMapping官方解释 SimpleUrlHandlerMapping实现HandlerMapping接口以

Spring mvc之SimpleUrlHandlerMapping

1.配置文件如下 <bean id="method" class="com.xx.controller.xxxController" scope="prototype"/> <!--控制层 方法与发布应用路径映射 所有控制层的方法映射全配置在这里 --> <bean id="simpleUrlHandlerMapping" class="org.springframework.web.s

Spring Cloud ZooKeeper集成Feign的坑2,服务调用了一次后第二次调用就变成了500,错误:Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.n

错误如下: 2017-09-19 15:05:24.659 INFO 9986 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.spring[email protected]56528192: startup date [Tue Sep 19 15:05:24 CST 2017]; root of context hierarchy 2017-09-19 15:05:24.858 INFO 9986 --

SpringMVC的实现过程

Spring Web MVC 处理Http请求的大致过程: 一旦Http请求到来,DispatcherSevlet将负责将请求分发.DispatcherServlet可以认为是Spring提供的前端控制器,所有的请求都有经过它来统一分发. 在DispatcherServlet将请求分发给Spring Controller之前,需要借助于Spring提供的HandlerMapping定位到具体的Controller.HandlerMapping是这样一种对象,它能够完成客户请求到Controlle

spring mvc

<dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId