當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
SSM-SpringMVC-07:SpringMVC中处理器映射器
生活随笔
收集整理的這篇文章主要介紹了
SSM-SpringMVC-07:SpringMVC中处理器映射器
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
?
?
?------------吾亦無他,唯手熟爾,謙卑若愚,好學若饑-------------
?
?
BeanNameUrlHandlerMapping和SimpleUrlHandlerMapping
?
BeanNameUrlHandlerMapping屬于springmvc默認的處理器映射器,配不配這個都可以
因為它在springmvc的配置文件已經(jīng)配置過了
?
自己也可以再配置一下BeanNameUrlHandlerMapping,不過沒什么用,在自己的xml配置文件中:
?
<!--處理器映射器,寫不寫都行,這個默認值就這個--><bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"></bean>?
?
SimpleUrlHandlerMapping處理器映射器配置:
自己的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: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/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"><!--配置bean處理器--><bean id="second" class="cn.dawn.day03simpleUrlHandlerMapping.FirstController"></bean><!--視圖解析器--><bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/"></property><property name="suffix" value=".jsp"></property></bean><!--處理器映射器--><bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"><!--第一種方式--><!--<property name="urlMap"><map><entry key="/hello"><value>second</value></entry></map></property>--><!--第二種方式--><property name="mappings"><props><!--value值為上面那個映射器的id--><prop key="/hello">second</prop></props></property></bean></beans>?
然后我可以通過/hello來訪問second那個處理器
?
總結(jié)
以上是生活随笔為你收集整理的SSM-SpringMVC-07:SpringMVC中处理器映射器的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Spring框架中的Quartz定时任务
- 下一篇: 1台路由连接两个网络-一台路由器有两个网