javascript
SpringMVC框架介绍
?1、 SpringMVC通過一套MVC注解,讓POJO成為處理請求的控制器,而無須實(shí)現(xiàn)任何接口。
? ? 2、支持REST風(fēng)格的URL請求。
????3、采用了松散耦合可插拔組件結(jié)構(gòu),比其他MVC框架更具擴(kuò)展性和靈活性。?
? ? 4、?配置web.xml文件
4.1 配置DispatcherServlet:默認(rèn)加載/WEB-INF/<servletName-servlet>.xml的Spring配置文件,啟動WEB層的Spring容器。可以通過contextConfigLocation初始化參數(shù)自定義配置文件的位置和名稱。
<servlet>
<servlet-name>springMvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- Spring MVC相關(guān)配置文件路徑?-->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:/spring-*.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springMvc</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>?
4.2 ?配置自動掃描的包
<!--?掃描業(yè)務(wù)組件,讓spring不掃描帶有@Service注解的類(留在root-context.xml中掃描@Service注解的類),防止事務(wù)失效?-->
<context:component-scan?base-package="com.hsmdata.qualityinspect">
<context:include-filter?type="annotation"?expression="org.springframework.stereotype.Controller"?/>?
<context:exclude-filter?type="annotation"?expression="org.springframework.stereotype.Service"?/>
<context:exclude-filter?type="annotation"?expression="org.springframework.stereotype.Repository"/>
</context:component-scan>
?4.3?配置視圖解析器
<!--?對轉(zhuǎn)向頁面的路徑解析。prefix:前綴,?suffix:后綴?-->
<bean?class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property?name="prefix"?value="/WEB-INF/jsp/"></property>
<property?name="suffix"?value=".jsp"></property>
</bean>
??
轉(zhuǎn)載于:https://www.cnblogs.com/esther-qing/p/5899762.html
總結(jié)
以上是生活随笔為你收集整理的SpringMVC框架介绍的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MyISAM和InnoDB的索引在实现上
- 下一篇: 人性 - 社会 - 经济 - 科学