<!--视图解析器-->
<!--DispatcherServlet会查找一个视图解析器来将控制器返回的逻辑视图名称转换成渲染结果的实际视图,
视图解析器的工作是将逻辑视图的名字与org.springframework.web.servlet.view的实现相匹配,可以认为,
视图解析器所做的就是将视图名称与JSP进行匹配。spring提供多种视图解析器选择,这里选择InternalResourceViewResolver-->
<!--依照约定优于配置,InternalResourceViewResolver将逻辑视图解析为View对象,而该对象将渲染的任务委托给Web应用程序
上下文中的一个模板(通常JSP),它通过为逻辑视图名称添加前缀和后缀来确定Web应用程序中模板的路径。-->
<!--假设应用的所有JSP放在"/WEB-INF/views/"目录下,即有如下的配置-->
<beanclass="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!--默认值,可不配置<propertyname="viewClass"value="org.springframework.web.servlet.view.JstlView"></property>-->
<propertyname="prefix"value="/WEB-INF/views/"></property>
<propertyname="suffix"value=".jsp"></property>
</bean>
</beans>
3.springContext.xml
<?xmlversion="1.0"encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation=
"http://www.springframework.org/schema/mvcmvc/spring-mvc-3.0.xsd
://www.springframework.org/schema/beans/spring-beans-3.0.xsd
://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!--扫描注解实体bean-->
<context:component-scanbase-package="com.aries.mo"use-default-filters="false">
<context:include-filtertype="annotation"expression="org.springframework.stereotype.Service"/>
<context:include-filtertype="annotation"expression="org.springframework.stereotype.Component"/>
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-55464-4.html
不让回复