首页 > 代码库 > what is a resolver
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。