課程
/后端開發(fā)
/Java
/Spring MVC起步
如mvc-dispatcher-servlet.xml文件配置,有模版么?有的話在哪找?
2015-07-14
源自:Spring MVC起步 3-5
正在回答
老的項目,官方的example...
HenryT
各位觀眾,我來幫你們省時間,mvc-dipatcher-servlet.xml請拿去:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="?
? ? ? ? http://www.springframework.org/schema/beans? ?
? ? ? ? http://www.springframework.org/schema/beans/spring-beans.xsd?
? ? ? ? http://www.springframework.org/schema/context? ?
?? http://www.springframework.org/schema/context/spring-context.xsd?
? ? ? ? http://www.springframework.org/schema/mvc? ?
? ? ? ? http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- 定義掃描Controller包下的內(nèi)容 -->
<context:annotation-config />
<!-- <context:annotation-config/> -->
<!-- 對module包中的所有類進行掃描,以完成Bean創(chuàng)建和自動依賴注入的功能 -->
<context:component-scan
base-package="com.imooc.mvcdemo">
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
<!-- @Controller注解的使用前提配置 詳細(xì)解釋見(注. 1. ) -->
<mvc:annotation-driven />
<!-- 啟動Spring MVC的注解功能,完成請求和注解POJO的映射 <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"?
/> -->
<!-- 定義視圖解析器,在視圖模型前后添加前綴后綴 暫時只支持jsp后綴 -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsps/" /><!-- 路徑前綴 -->
<property name="suffix" value=".jsp" /><!-- 后綴 -->
</bean>
</beans>
舉報
Java中Spring MVC框架入門教程,快來看最易用的MVC框架
2 回答配置文件敢不敢收敲一下?
2 回答默默地把配置文件敲了出來···
2 回答pom.xml第一行報錯
1 回答配置是什么意思?
1 回答三個配置文件,都是干什么的,求大神解釋
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2015-08-02
老的項目,官方的example...
2018-12-14
各位觀眾,我來幫你們省時間,mvc-dipatcher-servlet.xml請拿去:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="?
? ? ? ? http://www.springframework.org/schema/beans? ?
? ? ? ? http://www.springframework.org/schema/beans/spring-beans.xsd?
? ? ? ? http://www.springframework.org/schema/context? ?
?? http://www.springframework.org/schema/context/spring-context.xsd?
? ? ? ? http://www.springframework.org/schema/mvc? ?
? ? ? ? http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- 定義掃描Controller包下的內(nèi)容 -->
<context:annotation-config />
<!-- <context:annotation-config/> -->
<!-- 對module包中的所有類進行掃描,以完成Bean創(chuàng)建和自動依賴注入的功能 -->
<context:component-scan
base-package="com.imooc.mvcdemo">
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
<!-- @Controller注解的使用前提配置 詳細(xì)解釋見(注. 1. ) -->
<mvc:annotation-driven />
<!-- 啟動Spring MVC的注解功能,完成請求和注解POJO的映射 <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"?
/> -->
<!-- 定義視圖解析器,在視圖模型前后添加前綴后綴 暫時只支持jsp后綴 -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsps/" /><!-- 路徑前綴 -->
<property name="suffix" value=".jsp" /><!-- 后綴 -->
</bean>
</beans>