码迷,mamicode.com
首页 > 其他好文 > 详细

what is a resolver

时间:2016-10-09 17:24:31      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:

resolver [r?‘z?lv?] 解析器

ViewResolver

The ViewResolver provides a mapping between view names and actual views.

Map<java.lang.String, org.springframework.web.servlet.View> map = null;

{view names : actual views}

举例1:

在 Controller 中 某个方法 return "s1"

经过 处理

    <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>

之后

DispatcherServlet:1251 - Rendering view [org.springframework.web.servlet.view.JstlView: name ‘s1‘; URL [/WEB-INF/jsp/s1.jsp]] in DispatcherServlet with name ‘dispatcher‘

 

举例2:

PathMatchingResourcePatternResolver.class

如下

<context:component-scan base-package="cn.zno.s1" />

通过 patternResolver 处理之后

2016-10-04 10:29:17 DEBUG PathMatchingResourcePatternResolver:317 - Resolved classpath location [cn/zno/s1/] to resources [URL [file:/D:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/zmvc/WEB-INF/classes/cn/zno/s1/]]
2016-10-04 10:29:17 DEBUG PathMatchingResourcePatternResolver:711 - Looking for matching resources in directory tree [D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\zmvc\WEB-INF\classes\cn\zno\s1]
2016-10-04 10:29:17 DEBUG PathMatchingResourcePatternResolver:773 - Searching directory [D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\zmvc\WEB-INF\classes\cn\zno\s1] for files matching pattern [D:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/zmvc/WEB-INF/classes/cn/zno/s1/**/*.class]
2016-10-04 10:29:17 DEBUG PathMatchingResourcePatternResolver:483 - Resolved location pattern [classpath*:cn/zno/s1/**/*.class] to resources [file [D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\zmvc\WEB-INF\classes\cn\zno\s1\Test.class]]

 

最终得到pattern [classpath*:cn/zno/s1/**/*.class]

再扫描得到spring bean

 

resolver 的作用就是化繁为简,将简单的经过解析翻译成为最终需要的

全路径

然后再

 

what is a resolver

标签:

原文地址:http://www.cnblogs.com/zno2/p/5930303.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!