what is a resolver

Posted zno2

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了what is a resolver相关的知识,希望对你有一定的参考价值。

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的主要内容,如果未能解决你的问题,请参考以下文章

Androidproject中增加图片,报错cannot be resolved or is not a field

What is a shell and what is Bash?

Eclipse Android项目 为控件添加了Id,但是在Java代码中提示xxx cannot be resolved or is not a field

What is the reason that a likelihood function is not a pdf?

What is a CGFloat?

高中必修3Module 3 Period 1 Reading— What Is a Tornado?翻译!急!急!!急!!!