Spring MVC

 

1、什麼是SpringMVCweb

  SpringMVC是Spring家族的一員,Spring是將如今開發中流行的組件進行組合而成的一個框架!它用在基於MVC的表現層開發,spring

相似於struts2框架express

  

 

2、導入jar包mvc

  在官網上下載spring jar包,具體操做網上有,就不贅述了。app

  導包時只需導入如下8個包便可,也能夠所有導入,無影響。框架

  

前6個是Spring的核心功能包【IOC】,第7個是關於web的包,第8個是SpringMVC包ide

  • org.springframework.context-3.0.5.RELEASE.jar
  • org.springframework.expression-3.0.5.RELEASE.jar
  • org.springframework.core-3.0.5.RELEASE.jar
  • org.springframework.beans-3.0.5.RELEASE.jar
  • org.springframework.asm-3.0.5.RELEASE.jar
  • commons-logging.jar
  • org.springframework.web-3.0.5.RELEASE.jar
  • org.springframework.web.servlet-3.0.5.RELEASE.jar

 

3、註冊url

  

<!-- 註冊springmvc框架核心控制器 -->
<servlet>
<servlet-name>DispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!--到類目錄下尋找咱們的配置文件-->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:hello.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>DispatcherServlet</servlet-name>
<!--映射的路徑爲.action-->
<url-pattern>*.action</url-pattern>
</servlet-mapping>
View Code
<!--
註冊控制器
name屬性的值表示的是請求的路徑【也就是說,當用戶請求到/helloAction時,就交由HelloAction類進行處理】
-->
<bean class="HelloAction" name="/hello.action"></bean>  
View Code
相關文章
相關標籤/搜索